Syntax For Creating and Deleting Foreign Key
Let’s see the Foreign Key syntax used for creating a table.
Syntax for Creating Foreign Key:
CREATE TABLE Child_table_name (
Child_Column1 data_type,
Child_Column2 data_type, …,
FOREIGN KEY (Child_foreign_key_column)
REFERENCES referenced_table_name (referenced_primary_key_column) );
Below syntax is used to delete the foreign key in DBMS.
Syntax for Dropping Foreign Key:
ALTER TABLE Child_table_name
DROP FOREIGN KEY Child_foreign_key_name;
Foreign Key in DBMS
In DBMS, there are different types of keys available that are used for various purposes. Foreign Key is a column that refers to the primary key/unique key of another table. So it demonstrates the relationship between tables and acts as the cross reference among them.
Contact Us