Connecting to Oracle Database 21c
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 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 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;
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 ) );
shell> sqlplus C##user_id/password@xe @create.sql