You can add check constraints to your table or nickname.
A check constraint sets restrictions on data added to the table or
nickname. Check constraints are enforced when rows in the table or
nickname are inserted or updated. You can define a check constraint
that references a single column.
Before you begin
To
add check constraints, you must have at least one of the following
privileges on the table to be altered:
- ALTER privilege
- CONTROL privilege
- DBADM authority
- ALTERIN privilege on the schema of the table
Procedure
- To add check constraints using the Control Center:
- Open the Alter Table notebook if
you are adding a unique key to a table: From the Control Center, expand
the object tree until you find the Tables folder.
Click the Tables folder. Any existing tables
are displayed in the pane on the right side of the window. Right-click
the table you want in the contents pane and select Alter from
the pop-up menu. The Alter Table notebook opens.
If you are adding check constraints on a nickname, open the Alter
Nickname notebook.
- On the Check Constraints page,
click Add. The Add
Check Constraint window opens.
- For as many check constraints as you are adding: Specify
the check condition for the constraint that you are defining, type
a name for the check constraint, and optionally type a comment to
document the new check constraint.
- To add a check constraint using the command line, use the
ALTER TABLE statement.