CHECK Clause
A check constraint designates a condition that must be met before data can be inserted into a column.
This syntax fragment is part of the Single-Column Constraint Format.
During an insert or update, if a row returns false for any check constraint defined on a table, the database server returns an error. No error is returned, however, if a row returns NULL for a check constraint. In some cases, you might want to use both a check constraint and a NOT NULL constraint.
Check constraints are defined using search conditions. The search condition cannot contain user-defined routines, subqueries, aggregates, host variables, or rowids. In addition, the condition cannot contain the variant built-in functions CURRENT, SYSDATE, USER, CURRENT_USER, SITENAME, DBSERVERNAME, or TODAY.
The check constraint cannot include columns in different tables. When you are using the ADD or MODIFY clause, the check constraint cannot depend upon values in other columns of the same table.
0
: ALTER TABLE items ADD (unit_price MONEY (6,2) CHECK (unit_price > 0));
ALTER TABLE items ADD CONSTRAINT CHECK (unit_price < total_price);
When you create or enable a check constraint, you can speed up the statement by including the NOVALIDATE keyword to skip the checking of existing rows for violations. The check constraint is enabled when the statement completes.