Sybase 12.4.2 Server User Manual


 
Using table and column constraints
280
Working with column constraints in Sybase Central
All adding, altering, and deleting of column constraints in Sybase Central is
carried out in the Constraints tab of the column properties sheet.
To display the property sheet for a column:
1 Connect to the database.
2 Click the Tables folder for that database, and click the table holding the
column you wish to change.
3 Double-click the Columns folder to open it, and double-click the column
to display its property sheet.
For more information, see the Sybase Central online Help.
Using CHECK conditions on tables
A CHECK condition can be applied as a constraint on the table, instead of on
a single column. Such CHECK conditions typically specify that two values in
a row being entered or modified have a proper relation to each other. Column
CHECK conditions are held individually in the system tables, and can be
replaced or deleted individually. This is more flexible behavior, and CHECK
conditions on individual columns are recommended where possible.
For example, in a library database, the
date_returned column for a particular
entry must be later than (or the same as) the
date_borrowed entry:
ALTER TABLE loan
ADD CHECK(date_returned >= date_borrowed) UNENFORCED
Modifying and deleting CHECK conditions
There are several ways to alter the existing set of CHECK conditions on a table.
You can add a new CHECK condition to the table or to an individual
column, as described above.
You can delete a CHECK condition on a column by setting it to NULL.
The following statement removes the CHECK condition on the
phone
column in the
customer table:
ALTER TABLE customer MODIFY phone
CHECK NULL