Changing a foreign key

Use the Change Foreign Key window to modify a foreign key for the table that you're creating or altering. These steps are part of the larger tasks of creating a table and altering a table. When you complete these steps, return to either creating a table or altering a table.



To change a foreign key:

  1. Optional: In the Change Foreign Key window, select a different parent table:

    1. Use the Table owner box to specify the user identifier that owns the new parent table.

    2. Use the Table name box to specify the name of the new parent table. It must have a unique index, exist at the current subsystem, and must not be a catalog table.

  2. Optional: In the Unique indexes box, select a different parent table column key (primary or unique) to reference for this foreign key. The Index columns box displays a list of the columns defined for the selected key.

  3. Optional: Select different foreign key columns:

    1. In the Available columns box, select a column or columns that you want to define as a foreign key. The foreign key must have the same number of columns as the parent key has. Except for their names, default values, null attributes, and check constraints, each column that you select must match a column for the parent key. If a column of the foreign key has a field procedure, the corresponding column of the parent key must have the same field procedure and an identical field description.

      You can specify up to 64 columns, and the sum of their lengths must not exceed 254 minus the number of nullable columns.

      The foreign key is a duplicate if the foreign key and parent table are the same as those of a foreign key previously defined for this table. A duplicate foreign key is ignored with a warning.

    2. Click on the > push button to move the selected column or columns to the Foreign key columns box. The order of the foreign key columns must match the order of the parent key columns.

  4. Optional: Change the option specified in the On delete box.

  5. Optional: Change the name of the constraint by typing a new name in the Constraint name box. It must be different from the names of any referential or check constraints previously specified on the table.

  6. Click OK to make the changes you specified for the foreign key and close the Change Foreign Key window.

Depending on the task that you were doing when you changed this foreign key, return to either creating a table or altering a table.