You can change foreign keys for your table or nickname.
A foreign key is a column or set of columns in a table or nickname
whose values are required to match at least one primary key value
of a row of its parent table or nickname.
Before you begin
To
alter a table with a foreign key, 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
About this task
A
referential constraint is the rule that the values of the foreign
key are valid only if either:
- They appear as values of a parent key (primary key).
- Some component of the foreign key is null.
Procedure
- To change foreign keys 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 altering a foreign key on a nickname, open the Alter
Nickname notebook.
- On the Keys page, select a foreign
key and click Change. The Change
Foreign Key window opens.
- Optional: Select a different parent table or nickname.
- Specify the schema and name of the new parent table
or nickname.
- Optional: Select a new foreign key.
- Optional: Change the action specified for "on delete"
and "on update".
- Optional: Change the name of the constraint
- To change foreign keys using the command line, use the
ALTER TABLE statement.