Add a check constraint
Check constraints in System i Navigator are added to columns.
If you are adding a check constraint to a new table, follow the instructions for creating a table and
begin with step 6 when you get to the Table Definition dialog.
- In the System i Navigator window, expand the system you want to use.
- Expand Databases.
- Expand the database and schema that you want to work with.
- Click the Table container.
- Right-click the table to which you want to add the constraint and select Definition.
- On the Table Definition dialog, click the Check Constraints tab.
- On the Check Constraints tab, click New.
- On the Check Constraint Search Condition dialog, specify a name in the name text box. If
no name is specified, the system automatically generates a name.
- From the Columns list, double-click the column that you want to add the constraint to. The column appears
in the clause box.
- To insert an operator from the list, double-click it. The operator appears in the clause box.
- To insert a function from the list, double-click it. You can modify the list by selecting the
function type from the drop-down list. Once you have double-clicked the function, it will appear in the clause box.
- Modify the expression until it is correct.
- Click OK to return to the Table Definition dialog.
- Click OK to create the check constraint.
Note: You may modify a constraint only if it has been defined during your current table editing
session. If you added the constraint and then clicked OK on either the New Table dialog or Table
Definition dialog, then you have read only access for the constraint. If you want to change the
constraint properties, you must drop the constraint and then recreate it with the appropriate changes.