![]() REFERENCES supplier(supplier_id, supplier_name) We could also create a foreign key with more than one field as in the example below: CREATE TABLE supplierĬONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name) Then we've created a foreign key called fk_supplier on the products table that references the supplier table based on the supplier_id field. It consists of only one field - the supplier_id field. In this example, we've created a primary key on the supplier table called supplier_pk. column_n)ĬONSTRAINT supplier_pk PRIMARY KEY (supplier_id) REFERENCES parent_table (column1, column2. The syntax for creating a foreign key using a CREATE TABLE statement is: CREATE TABLE table_nameįOREIGN KEY (column1, column2.
0 Comments
Leave a Reply. |