SQL DROP CONSTRAINT is used within an ALTER TABLE or ALTER DOMAIN statement to delete a previously defined rule such as PRIMARY KEY, UNIQUE, CHECK, FOREIGN KEY, or EXCLUDE. Removing the constraint changes how the database enforces data integrity going forward but does not modify existing rows unless CASCADE is specified and the database performs additional actions (for example, dropping dependent indexes).Standard SQL defines the syntax ALTER TABLE table_name DROP CONSTRAINT constraint_name, with optional behavioral clauses like RESTRICT (default) or CASCADE. Some dialects extend this with IF EXISTS, ALTER DOMAIN DROP CONSTRAINT, or allow constraint type–specific shortcuts (e.g., MySQL’s DROP PRIMARY KEY, DROP FOREIGN KEY). Key points:- The statement requires ownership or ALTER privileges on the table.- Dropping a constraint referenced by other objects (indexes, foreign-key dependencies, views) may be blocked unless CASCADE is supplied.- Constraints created implicitly by the system (for example, indexes backing PRIMARY KEY or UNIQUE) are typically removed automatically.- NOT NULL constraints are dropped with ALTER TABLE ALTER COLUMN column_name DROP NOT NULL rather than DROP CONSTRAINT.- Always verify that application logic or other tables do not rely on the constraint before removal.
table_name
(identifier) - The target table that owns the constraint.constraint_name
(identifier) - The name of the constraint to remove.CASCADE
(keyword) - Automatically drop objects that depend on the constraint.RESTRICT
(keyword) - Refuse to drop if any dependent objects exist (default).IF EXISTS – keyword
(dialect specific) - Do nothing if the constraint is absent.ALTER TABLE, ADD CONSTRAINT, CREATE TABLE, DROP INDEX, ALTER COLUMN, CASCADE
SQL-92
Use CASCADE to let the database remove dependent objects automatically, or remove the dependencies manually first and rerun DROP CONSTRAINT.
No. NOT NULL is modified with ALTER TABLE ALTER COLUMN column_name DROP NOT NULL.
Yes. The supporting unique index is deleted automatically in most databases.
No. It only stops future enforcement. Existing rows stay as they are, even if they break the former rule.