The DROP CONSTRAINT command is utilized to remove a constraint like UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK from a database table.
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; |
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; |
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; |
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; |