Contents Index Using CHECK constraints on columns Inheriting column CHECK constraints from domains

ASA SQL User's Guide
  Ensuring Data Integrity
    Using table and column constraints

Using CHECK constraints on tables


A CHECK condition applied as a constraint on the table typically ensures that two values in a row being added or modified have a proper relation to each other.

When you give a name to the constraint, the constraint is held individually in the system tables, and you can replace or delete them individually. Since this is more flexible behavior, it is recommended that you either name a CHECK constraint or use an individual column constraint wherever possible.

For example, in a library database, the date_borrowed must come before the date_returned.

ALTER TABLE loan
ADD CONSTRAINT valid_date CHECK(date_returned >= date_borrowed)

For more information, see ALTER TABLE statement.


Contents Index Using CHECK constraints on columns Inheriting column CHECK constraints from domains