CREATE TABLE statement
472
Column constraints are normally used unless the constraint references more
than one column in the table. In these cases, a table constraint must be used.
Constraints include the following:
♦
This allows arbitrary conditions to be verified. For example, a
CHECK
check constraint could be used to ensure that a column called Sex only
contains the values M or F.
No row in a table is allowed to violate a constraint. If an INSERT or
UPDATE statement would cause a row to violate a constraint, the
operation is not permitted and the effects of the statement are undone.
The change is rejected only if a constraint condition evaluates to
FALSE, the change is allowed if a constraint condition evaluates to
TRUE or UNKNOWN.
$
For more information about TRUE, FALSE, and UNKNOWN
conditions, see "NULL value" on page 260 and "Search conditions" on
page 239.
♦
The COMPUTE constraint is a column constraint only.
COMPUTE
When a column is created using a COMPUTE constraint, its value in
any row is the value of the supplied expression. Columns created with
this constraint are read-only columns for applications: the value is
changed by the database server when the expression is evaluated.
Any UPDATE statement that attempts to change the value of a
computed column does fire any triggers associated with the column.
$
The Compute constraint is particularly useful when designing
databases using Java class data types. For more information, see "Using
computed columns with Java classes" on page 586 of the book ASA
User's Guide.
♦
Identifies one or more columns that uniquely identify each
UNIQUE
row in the table. No two rows in the table can have the same values in
all the named column(s). A table may have more than one unique
constraint.
There is a difference between a unique constraint and a unique index.
Columns of a unique index are allowed to be NULL, while columns in a
unique constraint are not. A foreign key can reference either a primary
key or a column with a unique constraint, but not a unique index,
because it can include multiple instances of NULL.
$
For information on unique indexes, and on the WITH HASH
clause, see "CREATE INDEX statement" on page 448.
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers