Setting up a Database


Connecting to Oracle Database 12c
undcemcs02> sqlplus C##user.id/password@//65.52.222.73:1521/cdb1 
SQL*Plus: Release 12.1.0.2.0 Production on Wed Sep 15 11:59:28 2021
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Last Successful login time: Tue Sep 07 2021 19:32:10 -05:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
  64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application
  Testing options

SQL>
Creating the inventory Table
SQL> CREATE TYPE  author_t  AS OBJECT ( name  VARCHAR(64) ); 
  2  / 
Type created.

SQL> CREATE TYPE  authors_t  AS VARRAY(10) OF  author_t; 
  2  / 
Type created.

SQL> CREATE TABLE  inventory ( 
  2    title     VARCHAR(64)  NOT NULL, 
  3    ISBN      CHAR(12)     PRIMARY KEY, 
  4    authors   authors_t    NOT NULL, 
  5    price     NUMBER(5,2)  NOT NULL  CHECK( price    >= 0.0 ), 
  6    quantity  INTEGER      NOT NULL  CHECK( quantity >= 0 ) ); 
Table created.

SQL> commit; 
Commit complete.

SQL> exit 
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
  64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
  options
undcemcs02>
Using a File of Statements to Create a Database
undcemcs02> cat  create.sql 

   DROP TABLE inventory;
   DROP TYPE  authors_t;
   DROP TYPE  author_t;

   CREATE TYPE  author_t  AS OBJECT ( name VARCHAR(64) ); 
   CREATE TYPE  authors_t AS VARRAY(10) OF author_t;

   CREATE TABLE  inventory ( 
     title     VARCHAR(64)  NOT NULL, 
     ISBN      CHAR(12)     PRIMARY KEY,
     authors   authors_t    NOT NULL, 
     price     NUMBER(5,2)  NOT NULL  CHECK( price >= 0.0 ),
     quantity  INTEGER      NOT NULL  CHECK( quantity >= 0 ) );

undcemcs02> sqlplus C##user.id/password@//65.52.222.73:1521/cdb1  @create.sql 




      Let the cat out of the bag.