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
ALTER TABLE table_name DROP CONSTRAINT constraint_name;
SQL DROP a UNIQUE Constraint
ALTER TABLE Patients 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
ALTER TABLE Doctors DROP CONSTRAINT PK_Doctors;
Note: Not supported in SQLite. Primary keys cannot be dropped using
ALTER TABLE
.
SQL DROP a FOREIGN KEY Constraint
ALTER TABLE Appointments DROP CONSTRAINT FK_DoctorAppointment;
Note: Not supported in SQLite. Foreign keys cannot be dropped using
ALTER TABLE
.
SQL DROP a CHECK Constraint
ALTER TABLE MedicalRecords DROP CONSTRAINT CHK_Temperature;
Note: Not supported in SQLite. Check constraints cannot be dropped using
ALTER TABLE
.