CREATE FOREIGN KEY statement
The CREATE FOREIGN KEY statement defines a foreign key for a table’s referential integrity checking.

CREATE FOREIGN KEY tableOwner 1.tableName 1 | Specifies the name of the constraint for the foreign key. CREATE FOREIGN KEY tableOwner1.tableName1.constraintName specifies the fully qualified name. If constraintName is not specified, Db2 automatically generates a name. | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
REFERENCETB tableOwner 2. tableName 2 | Specifies the name of the table to which the foreign key references. | ||||||||||
KEYCOLUMNS (columnName, ...) | Specifies the columns that are included in the definition of the foreign key. | ||||||||||
REFCOLUMNS (columnName, ...) | Specifies the names of the parent key columns. | ||||||||||
ON DELETE | Specifies the new rule that determines the action to take when a row of the parent table for the foreign key is deleted. ON DELETE parameter values
| ||||||||||
ENFORCED | Specifies whether Db2 enforces the referential constraint. ENFORCED parameter values
|
Related topic