Description

The SQL keyword DROP CONSTRAINT is used to delete an existing constraint, which deletes the constraint permanently from a table.

  • This keyword is not used in MySQL but used in database systems like SQL Server, Oracle, and MS Access.
  • In MySQL, it uses some other keywords to delete constraints.

The below table lists the syntactical differences between the database systems.

DROP Constraint SQL Server / Oracle / MS Access MySQL
UNIQUE Constraint ALTER TABLE customers
DROP CONSTRAINT UC_Customer;
ALTER TABLE customers
DROP INDEX UC_Customer;
PRIMARY KEY Constraint ALTER TABLE customers
DROP CONSTRAINT PK_Customer;
ALTER TABLE customers
DROP PRIMARY KEY;
FOREIGN KEY Constraint ALTER TABLE orders
DROP CONSTRAINT FK_CustomerOrder;
ALTER TABLE orders
DROP FOREIGN KEY FK_CustomerOrder;
CHECK Constraint ALTER TABLE customers
DROP CONSTRAINT CHK_CustomerAge;
ALTER TABLE customers
DROP CHECK CHK_CustomerAge;
DEFAULT Constraint ALTER TABLE customers
ALTER COLUMN city DROP DEFAULT;
ALTER TABLE customers
ALTER city DROP DEFAULT;

Related Links