![]() Both constraints are table-level constraints, where the former specifies the primary key and the latter the foreign key of the works_on table. The works_on table in Example 1 is specified with two declarative integrity constraints: prim_works and foreign_works. You have to drop theworks_ontable before you execute the following example. Example 1 shows the specification of the foreign key in the works_on table of the sample database. The table that contains the foreign key is called the referencing table, and the table that contains the corresponding primary key is called the parent table or referenced table. The number and the data types of the columns in the FOREIGN KEY clause must match the number and the corresponding data types of columns in the REFERENCES clause (and, of course, both of these must match the number and data types of the columns in the primary key of the referenced table). The REFERENCES clause specifies the table name with all columns that build the corresponding primary key. The FOREIGN KEY clause defines all columns explicitly that belong to the foreign key. The FOREIGN KEY clause has the following form: Each foreign key is defined using the FOREIGN KEY clause combined with the REFERENCES clause. ![]() ![]() A foreign key is a column or group of columns in one table that contains values that match the primary key values in the same or another table. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |