Contents Index Using CHECK constraints on tables Working with table and column constraints in Sybase Central

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

Inheriting column CHECK constraints from domains


You can attach CHECK constraints to domains. Columns defined on those data types inherit the CHECK constraints. A CHECK constraint explicitly specified for the column overrides that from the domain.

Any column defined using the posint data type accepts only positive integers unless the column itself has a CHECK constraint explicitly specified. In the following example, the domain accepts only positive integers. Since any variable prefixed with the @ sign is replaced by the name of the column when the CHECK constraint is evaluated, any variable name prefixed with @ could be used instead of @col.

CREATE DATATYPE posint INT
CHECK ( @col > 0 )

An ALTER TABLE statement with the DELETE CHECK clause deletes all CHECK constraints from the table definition, including those inherited from domains.

Any changes made to constraint in a domain definition after a column is defined on that domain are not applied to the column. The column gets the constraints from the domain when it is created, but there is no further between the two.

For more information about domains, see Domains.


Contents Index Using CHECK constraints on tables Working with table and column constraints in Sybase Central