Adding a Foreign Key While Creating a Table

How To

You can choose a foreign key as well as select foreign key options. Foreign key columns in the referencing table must map exactly to the primary key columns or unique index columns of the referenced table. The number of columns used in the foreign key and the schema of those columns must be the same in both the referencing and referenced tables.

A foreign key ensures referential integrity between two tables. How it performs this depends on the action chosen for the foreign key. When a record in the referenced column(s) is deleted or updated, the foreign key performs the action on the referencing column(s). The possible actions follow:


Related topic:

Creating a Table
Adding a UNIQUE Constraint

Setting Advanced Table Options

Using Foreign Keys