Setting up a Database


Connecting to Oracle Database 12c
shell> sqlplus C##user_id/password@xe 

SQL*Plus: Release 23.0.0.0.0 - Production on Sun Aug 18 10:54:34 2024
Version 23.4.0.24.05

Copyright (c) 1982, 2024, Oracle.  All rights reserved.
Last Successful login time: Sun Aug 18 2024 01:01:49 -05:00

Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

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

SQL> commit; 
Commit complete.

SQL> exit 
Disconnected from Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
    
shell>
Using a File of Statements to Create a Database
shell> cat  create.sql 

   DROP TABLE inventory;

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

shell> sqlplus C##user_id/password@xe  @create.sql 




      Let the cat out of the bag.