Constraints

The Db2 for i database supports unique, referential, and check constraints.

A unique constraint is a rule that guarantees that the values of a key are unique. A referential constraint is a rule that all non-null values of foreign keys in a dependent table have a corresponding parent key in a parent table. A check constraint is a rule that limits the values allowed in a column or group of columns.

Db2 for i enforces the validity of the constraint during any data manipulation language (DML) statement. Certain operations (such as restoring the dependent table), however, cause the validity of the constraint to be unknown. In this case, DML statements might be prevented until Db2 for i has verified the validity of the constraint.

  • Unique constraints are implemented with indexes. If an index that implements a unique constraint is not valid, the Edit Rebuild of Access Paths (EDTRBDAP) command can be used to display any indexes that currently require being rebuilt.
  • If Db2 for i does not currently know whether a referential constraint or check constraint is valid, the constraint is considered to be in a check pending state. The Edit Check Pending Constraints (EDTCPCST) command can be used to display any indexes that currently require being rebuilt.