Using Check Constraints

Tables and columns can contain multiple CHECK constraints. A CHECK constraint can validate a column value against a logical expression or another column in the same or another table. What you can't do with the CHECK constraint is specify the custom validation message, as is possible to do in the Access user interface.

The procedure in Hands-On 20-1 uses a PRIMARY KEY constraint explicitly named PrimaryKey to identify the Id column as a primary key. The CHECK constraint used in this procedure ensures that only numbers within the specified range are entered in the YearsWorked table column. You can apply CHECK constraints to a single column or to multiple columns. When a table is deleted, CHECK constraints are also dropped.

0 0

Post a comment