SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-86
Syntax Description of CREATE TABLE
For more information, see the entry for a specific attribute.
LIKE source-table [include-option]...
directs NonStop SQL/MX to create a table like the existing table, source-table,
omitting constraints (with the exception of the NOT NULL and NOT DROPPABLE
PRIMARY KEY constraints), headings, and partitions unless include-option
clauses are specified. The source-table must be the ANSI name of an SQL/MX
format table (you cannot specify an SQL/MP table).
ATTRIBUTE[S] attribute [,attribute]... and the STORE BY
store-option are copied from the source-table if they are not explicitly
specified as file options following the LIKE specification.
The include-option clauses are specified as:
WITH CONSTRAINTS
directs NonStop SQL/MX to use constraints from source-table. Constraint
names for table are randomly generated unique names. NonStop SQL/MX
does not include FOREIGN KEY table constraints or REFERENCES column
constraints.
This table show the results of specifying or not specifying WITH
CONSTRAINTS on primary key constraints:
When you perform a CREATE TABLE LIKE, whether or not you include the
WITH CONSTRAINTS clause, the target table will have all the NOT NULL
DROPPABLE column constraints that exist for the source table, plus all the
NOT NULL NOT DROPPABLE column constraints that exist for the source
table. They will have different constraint names.
WITH HEADINGS
directs NonStop SQL/MX to use column headings from source-table.
WITH
CONSTRAINTS
clause?
Source table
has...
Target table will have...
No DROPPABLE
primary key
constraint
No primary key constraint.
Yes DROPPABLE
primary key
constraint
The same DROPPABLE primary key constraint
with a different name.
With or without NOT
DROPPABLE
primary key
constraint
The same NOT DROPPABLE primary key
constraint with a different name.