SQL DROP CONSTRAINT Keyword
The DROP CONSTRAINT command is used to delete a UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK constraint from a table.
SQL DROP CONSTRAINT Syntax
SQL
x
1
ALTER TABLE table_name
2
DROP CONSTRAINT constraint_name;
SQL DROP a UNIQUE Constraint
SQL
1
1
ALTER TABLE Patients
2
DROP CONSTRAINT UC_Patients;
Note: This syntax is not supported in SQLite, including our TechKubo playground. SQLite does not support dropping constraints after table creation.
SQL DROP a PRIMARY KEY Constraint
SQL
1
1
ALTER TABLE Doctors
2
DROP CONSTRAINT PK_Doctors;
Note: Not supported in SQLite. Primary keys cannot be dropped using
ALTER TABLE
.
SQL DROP a FOREIGN KEY Constraint
SQL
1
1
ALTER TABLE Appointments
2
DROP CONSTRAINT FK_DoctorAppointment;
Note: Not supported in SQLite. Foreign keys cannot be dropped using
ALTER TABLE
.
SQL DROP a CHECK Constraint
SQL
1
1
ALTER TABLE MedicalRecords
2
DROP CONSTRAINT CHK_Temperature;
Note: Not supported in SQLite. Check constraints cannot be dropped using
ALTER TABLE
.