CREATE TABLE ord_items
(ord_no NUMBER(2),
item_no NUMBER(3),
qty NUMBER(3) CHECK (qty BETWEEN 100 AND 200),
expiry_date date CHECK (expiry_date > SYSDATE),
CONSTRAINT it_pk PRIMARY KEY (ord_no,item_no),
CONSTRAINT ord_fk FOREIGN KEY(ord_no) REFERENCES orders(ord_no));
-
约束条件必须是确定值,不能是变量。
ORA-02436: date or system variable wrongly specified in CHECK constraint
-
Cause: An attempt was made to use a date constant or system variable,
-
such as USER, in a check constraint that was not completely specified in
-
a CREATE TABLE or ALTER TABLE statement.
-
For example, a date was specified without the century.
-
Action: Completely specify the date constant or system variable.
-
Setting the event 10149 allows constraints like "a1 > '10-MAY-96'",
-
which a bug permitted to be created before version 8.