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 drop 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, you can add a constraint on the Employees table to ensure that the TerminationDate is always later than, or equal to, the StartDate:
ALTER TABLE Employees ADD CONSTRAINT valid_term_date CHECK( TerminationDate >= StartDate ); |
You can specify variables within table CHECK constraints but their names must begin with @. The value used is the value of the variable at the moment the DML or LOAD statement is executed.
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |