ALLBASE/SQL Reference Manual (36216-90216)

358 Chapter10
SQL Statements A - D
CREATE TABLE
UNIQUE | PRIMARY KEY specifies a unique constraint placed on the column. The table
level constraint { UNIQUE | PRIMARY KEY } (
ColumnName
) is
equivalent. See the discussion on table level unique constraints below.
REFERENCES specifies a Referential Constraint placed on the column. This is equivalent
to the table level constraint FOREIGN KEY (
ColumnName
)
REFERENCES
RefTableName
[(
RefColumnName
)]. See the discussion on
table level referential constraint below.
CHECK specifies a check constraint placed on the column.
SearchCondition
specifies a boolean expression that must not be false. The result of the
boolean expression may be unknown if a value in the expression is NULL.
See the discussion on a table level check constraint below. In addition, for a
column definition check constraint, the only column the search condition
can reference is
ColumnName
.
ConstraintID
is an optional name specified for the constraint. If none is supplied, one is
generated, as described under "Description" below.
DBEFileSetName3
specifies the DBEFileSet to be used for storing the section associated
with the check constraint. If not specified, the default SECTIONSPACE
DBEFileSet is used. (Refer to syntax for the SET DEFAULT DBEFILESET
statement.)
SQL Syntax—Unique Constraint (Table Level)
{UNIQUE
PRIMARY KEY}(
ColumnName
[,...]) [CONSTRAINT
ConstraintI
D]
Parameters—Unique Constraint (Table Level)
UNIQUE Each
ColumnName
shall identify a column of the table, and the same
column shall not be identified more than once. Also, NOT NULL shall be
specified for each column in this unique constraint column list.
PRIMARY KEY In addition to the rules for the UNIQUE option, PRIMARY KEY may only
be specified once in a table definition. It provides a shorthand way of
referencing its particular unique constraint column list in a referential
constraint.
ColumnName
[,...] is the unique constraint column list, or key list, of the constraint.
No two unique constraints may have identical column lists. The maximum
number of columns in a unique column list is 15. None of the columns may
be a LONG data type.
ConstraintID
is an optional name specified for the constraint. If none is supplied, one is
generated, as described under "Description" below.
SQL Syntax—Referential Constraint (Table Level)
FOREIGN KEY (
FKColumnName
[,...])
REFERENCES
RefTableName
[(
RefColumnName
[,...])] [CONSTRAINT
ConstraintID
]