Attach a check constraint to a table to specify the data values that are acceptable in one or more columns.
Note Some databases have different functionality for check constraints. For more information about the differences between databases, see Database Server Considerations. Consult your database documentation for details about how your database works with check constraints.
To attach a new check constraint
state
column of the authors
table to New York, type:state = 'NY'
Or, to require entries in the zip
column to be 5 digits, type:
zip LIKE '[0-9][0-9][0-9][0-9][0-9]'
Important Make sure to enclose any non-numeric constraint values in single quotation marks ('). For additional details, see Defining a Check Constraint Expression.
When you create a check constraint, it is automatically bound to the specified columns. It takes effect when you save the table or diagram. When you delete a table, all the check constraints attached to that table are automatically deleted.