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 identical in both the referencing and referenced tables.

A foreign key ensures referential integrity between two tables. The foreign key accomplishes this task according to 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 are:

Please note that the delete action of a foreign key may be different from the update action.