Oracle Check Constraint
Oracle check constraint insures that updated or
inserted values meet a specific condition. The Oracle check
constraint check condition
must return a TRUE or FALSE, much Like the WHERE clause. If
the Oracle check constraint condition returns as TRUE when you use Oracle check constraint,
the value is accepted by the constraint. If Oracle check constraint
returns the condition as FALSE, the value is rejected. Below, we
include an Oracle check constraint on the editor_active column of the
EDITOR table that insures the value is either Y or N.
To put it another way, Oracle check constraint
validates incoming columns at row insert time. With Oracle check
constraint, rather than having an application verify that all
occurrences of REGION are North, South, East, or West, an Oracle
CHECK constraint can be added to the table definition to ensure the
validity of the region column.
Here is an example of Oracle check constraint:
Oracle check constraint has some limitations.
For one, subqueries cannot be used within your Oracle check
constraints. Also, an Oracle check constraint is
able to reference another column. Sysdate, currval, nextval, level, rowid, uid, user or
userenv cannot be referenced with Oracle check constraint.
Oracle check constraint cannot reference columns
from other tables. There can be more than one Oracle check
constraint per column, however the values being checked with Oracle
check constraint must pass
all Oracle check constraints on that column before being acceptable.
Oracle check constraint can also be used to check multiple columns.
Oracle check constraint does
have some limitations in its ability to validate data. If more
than one capable Oracle check constraint is needed, triggers must be implemented.