Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

DROP CONSTRAINT

DROP CONSTRAINT

The DROP CONSTRAINT command is utilized to remove a constraint like UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK from a database table.

DROP a UNIQUE Constraint

To remove a UNIQUE constraint, employ the following SQL:

SQL Server / Oracle / MS Access:

ALTER TABLE Persons
DROP CONSTRAINT UC_Person; 

MySQL:

ALTER TABLE Persons
DROP INDEX UC_Person; 

DROP a PRIMARY KEY Constraint

To eliminate a PRIMARY KEY constraint, execute the following SQL:

SQL Server / Oracle / MS Access:

ALTER TABLE Persons
DROP CONSTRAINT PK_Person; 

MySQL:

ALTER TABLE Persons
DROP PRIMARY KEY

DROP a FOREIGN KEY Constraint

To remove a FOREIGN KEY constraint, utilize the following SQL:

SQL Server / Oracle / MS Access:

ALTER TABLE Orders
DROP CONSTRAINT FK_PersonOrder; 

MySQL:

ALTER TABLE Orders
DROP FOREIGN KEY FK_PersonOrder; 

DROP a CHECK Constraint

To eliminate a CHECK constraint, employ the following SQL:

SQL Server / Oracle / MS Access:

ALTER TABLE Persons
DROP CONSTRAINT CHK_PersonAge; 

MySQL:

ALTER TABLE Persons
DROP CHECK CHK_PersonAge;