Adding foreign keys when altering a table

Use the Add Foreign Key window to add foreign keys to your table. A foreign key is a column or set of columns in a table whose values are required to match at least one primary key value of a row of its parent table. A referential constraint is the rule that the values of the foreign key are valid only if either:

You can add multiple foreign keys before closing this window.

Fields and controls

Authorities and privileges



To add new foreign keys:

  1. In the Table schema box, specify the schema of the parent table.

  2. In the Table name box, specify the name of the parent table. The Primary key box displays a list of the primary key columns defined for the parent table.

  3. In the Available columns box, select a column or columns that you want to define as a foreign key. Each column you select must match a primary key column for the parent table in meaning and data type.

  4. Click on the > push button to move the selected column or columns to the Foreign key box.

  5. In the On delete box, specify what action is to take place on the dependent table when a row is deleted from the parent table.

  6. In the On update box, specify what action is to take place on the dependent table when a row of the parent table is updated.

  7. Optional: In the Constraint name field, type a name for the constraint that you're defining.

  8. Click on the Apply push button to add the new foreign key.

  9. Repeat steps 1 through 8 to add another foreign key to your table.

  10. Click on Cancel to close the Add Foreign Key window.

  11. If you do not want to make any additional changes to the table, click on OK to alter your table and close the Alter Table notebook. Otherwise, continue on to one or more of the optional tasks.


Related information