×
☰ See All Chapters

MySQL Dropping Constraints

Using the ALTER TABLE command with the DROP CONSTRAINT option, we can drop any constraint that we have defined. We can drop constraint either from column or completely from table. Dropping constraint from table will drop the constraint from all columns which have that constraint.

Dropping constraints on columns

This will drop the constraint from particular column. In the below example it will drop the constraint CUSTOMER_PK. Columns having the constraint with name CUSTOMER_PK will get its constraint removed.

ALTER TABLE CUSTOMER DROP CONSTRAINT CUSTOMER_PK;

 

Dropping constraints on tables

This will drop the constraint from particular table. This will drop the constraint from all columns has that constraint.

In the below example it will drop the constraint PRIMARY_KEY from all columns.

ALTER TABLE CUSTOMER DROP PRIMARY KEY;

 

 

 


All Chapters
Author