Prev | Next |
Check Constraints
A Check Constraint enforces domain integrity by limiting the values that are accepted by a column.
Access
Ribbon |
Specialize > Tools > Database Builder > Click on Table name > Constraints/Indexes > Right-click > Add New Constraint |
Context Menu |
In diagram | Right-click on Table | Features & Properties | Constraints/Indexes | Right-click | Add New Constraint |
Keyboard Shortcuts |
Click on Table: > Constraints/Indexes: |
Create a Constraint
Step |
Action |
See also |
---|---|---|
1 |
On the 'Constraints/Indexes' tab of the Columns and Constraints screen, a new constraint is automatically created and assigned the default constraint name and a 'Type' of index. Overtype the constraint name with a name that identifies the constraint as a check constraint, such as 'CHK_ColumnName' (the CHK_ prefix is optional). |
Database Table Constraints |
2 |
In the 'Type' field, change the value from 'index' to 'check'. |
|
3 |
In the 'Properties' panel for the Condition property, type the SQL statement that will be used as the Check Condition; for example, column1 < 1000. If the condition is long, click on the button to display a SQL editor (with syntax highlighting). |
Delete a Check Constraint
If you do not want to keep a check constraint, either:
- Right-click on it in the list and select 'Delete constraint <name>', or
- Click on the item and press
The constraint is immediately deleted.
Notes