Adding and removing referential constraints
You can use the CREATE TABLE statement or the ALTER TABLE statement to add a referential constraint. To remove a referential constraint, use the ALTER TABLE statement.
Constraints are rules that ensure that references from one table, a dependent table, to data in another table, the parent table, are valid. You use referential constraints to ensure referential integrity.
With a referential constraint, non-null values of the foreign key are valid only if they also appear as values of a parent key. When you define a referential constraint, you specify:
- A primary or unique key
- A foreign key
- Delete and update rules that specify the action taken with respect to dependent rows when the parent row is deleted or updated.
Optionally, you can specify a name for the constraint. If a name is not specified, one is automatically generated.
After a referential constraint is defined, the system enforces the constraint on every INSERT, DELETE, and UPDATE operation performed through SQL or any other interface including iSeries™ Navigator, CL commands, utilities, or high-level language statements.
Parent topic:
Referential integrity and tables
Related reference
CREATE TABLE
ALTER TABLE