Previous Topic: CREATE SCHEMA StatementNext Topic: CREATE SYNONYM Statement


CREATE TABLE Statement

CREATE TABLE table-name

Creates a table, a key, and an element for the entire table. It relates the TABLE entity-occurrence to the AUTHORIZATION entity-occurrence (the schema).

The following are the significant TABLE entity-occurrence attributes defined:

The element contains all the columns defined to the table. The following are the significant ELEMENT entity-occurrence attributes defined:

The first column named in the CREATE TABLE statement becomes the CA Datacom/DB Master and Native Key for the table except when a primary key is defined for the table. The following are the significant KEY entity-occurrence attributes defined:

IN area-name

Relates the TABLE entity-occurrence created to the AREA entity-occurrence named. If you do not include this parameter, the table is placed in the SQL default area (see the CA Datacom/DB Database and System Administration Guide).

CREATE TABLE table-name column-name

Defines a column (FIELD entity-occurrence) in the table. The following are the significant FIELD entity-occurrence attributes defined:

Additional attributes are defined based on the column definition syntax as follows.

datatype

Defines the column's data type through FIELD entity-occurrence attributes. If the column's data type is DATE, TIME, or TIMESTAMP:

FOR BIT DATA

For the FIELD entity-occurrence, specifies SEMANTIC-TYPE=BITDATA (only valid for character, VARCHAR, and LONG VARCHAR data types).

DEFAULT literal

For the FIELD entity-occurrence, defines a literal value in the VALUE attribute and sets the DEFAULT-INSERT attribute to O.

DEFAULT USER

For the FIELD entity-occurrence, sets the DEFAULT-INSERT attribute to U.

DEFAULT NULL

For the FIELD entity-occurrence, sets the NULL-INDICATOR attribute to Y and the DEFAULT-INSERT attribute to N.

DEFAULT SYSTEM USER

For the FIELD entity-occurrence, sets the DEFAULT-INSERT attribute to S.

NOT NULL

For the FIELD entity-occurrence, sets the NULL-INDICATOR attribute to N.

NOT NULL WITH DEFAULT

For the FIELD entity-occurrence, sets the DEFAULT-INSERT attribute to D.

WITH DEFAULT

For the FIELD entity-occurrence, sets the DEFAULT-INSERT attribute to D.

PRIMARY KEY

Creates a key consisting of this column or columns and a constraint. The following are the significant KEY entity-occurrence attributes defined:

The following are the significant CONSTRAINT entity-occurrence attributes defined:

The TABLE entity-occurrence has the following attributes that pertain to constraints:

UNIQUE

Defines a key consisting of the identified column or columns and a constraint. The following are the significant KEY entity-occurrence attributes defined:

The following are the significant CONSTRAINT entity-occurrence attributes defined:

The TABLE entity-occurrence has the following attributes that pertain to constraints:

REFERENCES table-name (column-list)

Sets the TABLE entity-occurrence CNS-REFERS= and CONSTRAINT= attributes to Y for this table.

Sets the referenced TABLE entity-occurrence CNS-REFERENCED= and CONSTRAINT= attributes to Y.

Also establishes a foreign key occurrence (see following page).

CHECK (search condition)

Creates a constraint. The following are the significant CONSTRAINT entity-occurrence attributes defined:

The TABLE entity-occurrence has the following attributes that pertain to constraints:

CONSTRAINT constraint-name

Sets the CONSTRAINT entity-occurrence SQLNAME attribute to the name specified in the statement.

FOREIGN KEY (column-list)

Creates a key consisting of the identified column or columns and a constraint. The following are the significant KEY entity-occurrence attributes defined:

The following are the significant CONSTRAINT entity-occurrence attributes defined:

The TABLE entity-occurrence has the following attributes:

Sets the referenced TABLE entity-occurrence CNS-REFERENCED= and CONSTRAINT= attributes to Y.