NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-155
Examples—CREATE TABLE
The following example creates a table with the primary key of the TIMESTAMP
data type and partitions the table on a TIMESTAMP value. Another column has the
TIME data type.
CREATE TABLE $VOL1.SUBV1.PARTTIME
( A TIMESTAMP DEFAULT CURRENT NOT NULL
, B TIME DEFAULT TIME "11:00:00" NOT NULL
, C VARCHAR(300) NO DEFAULT NOT NULL
, PRIMARY KEY A
)
PARTITION (
$VOL2.SUBV1.PARTTIME FIRST KEY TIMESTAMP
"1989-12-1:12:00:00.000000" );
The following sample column definitions show various combinations of DEFAULT,
NULL, and NOT NULL clauses and their effects.
Column PARTNUM can contain null values. Because no DEFAULT clause is
specified, the column is initialized to a null value when a row is inserted without
supplying a value for PARTNUM:
( ... PARTNUM NUMERIC (4) UNSIGNED ... )
Column DEPTNUM cannot contain null values. The user must supply a non-null
value when a row is inserted:
(... DEPTNUM NUMERIC (4) UNSIGNED NO DEFAULT NOT NULL ... )
Column ORDERNUM can contain null values. The column is initialized to a system
default value when a row is inserted without supplying a value for ORDERNUM:
( ... ORDERNUM NUMERIC (6) UNSIGNED DEFAULT SYSTEM ... )
Column EMPNUM cannot contain null values. The column is initialized to a system
default value when a row is inserted without supplying a value for EMPNUM:
(...EMPNUM NUMERIC (4) UNSIGNED DEFAULT SYSTEM NOT NULL...)
Column JOBCODE can contain null values. The user must supply a value for
JOBCODE when a row is inserted. The value supplied could be a null value:
( ... JOBCODE NUMERIC (4) UNSIGNED NO DEFAULT ... )