Database Reference
In-Depth Information
Scripted
. The CREATE TABLE command can be used to list each
column's attributes.
CREATE TABLE ... AS subquery
. The CREATE TABLE command
can be executed as a creation from a subquery.
Tools
. There are numerous tools available, which can be used to cre-
ate tables both in a graphical user interface (GUI) or as generated,
modifiable scripting.
18.1.2.1
Scripted Method
Examine the script shown following. This example is a part of the script
used to create the ARTIST table for the MUSIC schema (see Appendix A).
CREATE OR REPLACE TYPE
INSTRUMENTSCOLLECTION AS VARRAY(10) OF VARCHAR2(32);
/
CREATE TABLE ARTIST(
ARTIST_ID
NUMBER NOT NULL
, NAME
VARCHAR2(32) NOT NULL
, STREET
VARCHAR2(32)
, POBOX
CHAR(20)
, CITY
VARCHAR2(32)
, STATE_PROVINCE
VARCHAR2(32)
, COUNTRY
VARCHAR2(32)
, ZIP
CHAR(10)
, EMAIL
VARCHAR2(32)
, INSTRUMENTS
INSTRUMENTSCOLLECTION
, CONSTRAINT
XPKARTIST PRIMARY KEY (ARTIST_ID)
);
CREATE UNIQUE INDEX XUK_ARTIST_NAME ON ARTIST (NAME);
Each column has a name, a datatype, a size (if needed for the datatype),
and a position in the table. There are several points to note about the ART-
IST table creation script:
The ARTIST table is by definition an object table and not a rela-
tional table. Why? A very simple reason. The ARTIST table contains
an object as one of its object types. The INSTRUMENTS column is
an object collection column of the user-defined structural type
INSTRUMENTSCOLLECTION.
 
Search WWH ::




Custom Search