1.1.1

Table Of Contents
CHECK (
CHECK Constraint Search Condition
) |
{
PRIMARY KEY ( column-name [ , column-name ]* ) |
UNIQUE ( column-name [ , column-name ]* ) |
FOREIGN KEY ( column-name [ , column-name ]* )
REFERENCES table-name [ ( column-name [ , column-name ]* ) ]
[ ON DELETE RESTRICT ]
}
}
CHECK Constraint Search Condition
A search condition is a boolean expression that is specied in a CHECK constraint. The expression cannot be
dynamic and so cannot contain dynamic parameters, date/time functions, user functions, or sub-queries.
If a check constraint is included as part of a column-denition, a column reference can only be made to the same
column.
If a check constraint is specied as part of a table denition, column references can specify any columns that
were previously dened in the CREATE TABLE statement. When specied in a table constraint, the search
condition must be satised for all rows in the table. The search condition is applied to each row that is modied
on an INSERT or UPDATE at the time of the row modication. The entire statement is aborted if any check
constraint is violated.
Examples of Constraints
-- column-level primary key constraint named OUT_TRAY_PK:
CREATE TABLE SAMP.OUT_TRAY
(
SENT TIMESTAMP,
DESTINATION CHAR(8),
SUBJECT CHAR(64) NOT NULL CONSTRAINT OUT_TRAY_PK PRIMARY KEY,
NOTE_TEXT VARCHAR(3000)
);
-- the table-level primary key definition allows you to
-- include more than one columns in the primary key definition:
CREATE TABLE SAMP.SCHED
(
CLASS_CODE CHAR(7) NOT NULL,
DAY SMALLINT NOT NULL,
STARTING TIME,
ENDING TIME,
PRIMARY KEY (CLASS_CODE, DAY)
);
-- Use a column-level constraint for an arithmetic check
-- Use a table-level constraint
-- to make sure that a employee's taxes does not
-- exceed the bonus
CREATE TABLE SAMP.EMP
(
EMPNO CHAR(6) NOT NULL CONSTRAINT EMP_PK PRIMARY KEY,
FIRSTNME CHAR(12) NOT NULL,
MIDINIT vARCHAR(12) NOT NULL,
vFabric SQLFire User's Guide496
vFabric SQLFire Reference