SQL DROP FOREIGN KEY

To remove a foreign key from a table, use the ALTER TABLE with DROP CONSTRAINT command.

Syntax

Syntax to remove any foreign key from a table:

ALTER TABLE table_name DROP CONSTRAINT fk_name;

SQL FOREIGN KEY Constraint

The SQL FOREIGN KEY constraint The foreign key constraint ensures that the values in the foreign key column match the values in the primary key column of the referenced table, maintaining referential integrity.

Similar Reads

Foreign Key in SQL

A foreign key is a column or a combination of columns in a table that establishes a link between two tables in a relational database. It refers to the primary key in another table, creating a relationship between them....

SQL Foreign Key Constraint Example

In this example, we create a foreign key during the table creation....

SQL DROP FOREIGN KEY

To remove a foreign key from a table, use the ALTER TABLE with DROP CONSTRAINT command....

Important Points About SQL FOREIGN KEY Constraint

A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table.The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table.A table can have multiple FOREIGN KEY constraints.When defining a FOREIGN KEY constraint, you can specify what happens when a referenced row in the parent table is deleted or updated. This is done using the ON DELETE and ON UPDATE clauses followed by the CASCADE, SET NULL, or NO ACTION option.The FOREIGN KEY constraint in SQL is used to maintain the referential integrity of data within the database....