CHAPTER 7 Ensuring Data Integrity

You can replace a CHECK condition on a column in the same way as you would add a CHECK condition. The following statement adds or replaces an unenforced CHECK condition on the phone column of the customer table:

ALTER TABLE customer MODIFY phone

CHECK ( phone LIKE ’___-___-____’ )

UNENFORCED

There are two ways of modifying a CHECK condition defined on the table, as opposed to a CHECK condition defined on a column.

You can add a new CHECK condition using ALTER TABLE with an ADD table-constraint clause.

You can delete all existing CHECK conditions, including column CHECK conditions, using ALTER TABLE DELETE CHECK, and then add in new CHECK conditions.

All CHECK conditions on a table, including CHECK conditions on all its columns and CHECK conditions inherited from user-defined data types, are removed using the ALTER TABLE statement with the DELETE CHECK clause, as follows:

ALTER TABLE table_name

DELETE CHECK

Deleting a column from a table does not delete CHECK conditions associated with the column that are held in the table constraint. If the constraints are not removed, any attempt to query data in the table will produce a column not found error message.

Declaring entity and referential integrity

The relational structure of the database enables the database server to identify information within the database. Adaptive Server IQ also ensures that primary key-foreign key relationships between tables are properly upheld by all the rows in any join index relying on these relationships.

281

Page 301
Image 301
Sybase 12.4.2 manual Declaring entity and referential integrity, 281