bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL DROP Keyword

Concept visual

SQL DROP Keyword

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

DROP Keyword

Previous

❮ SQL Keywords

Next

Drop Column

The DROP COLUMN

command is used to delete a column in an existing table. The following SQL deletes the "ContactName" column from the "Customers" table:

Example

ALTER TABLE Customers

DROP COLUMN ContactName;

DROP a UNIQUE Constraint

To drop a UNIQUE constraint, use the following SQL:

Formula

SQL Server / Oracle / MS Access:

ALTER TABLE Persons

DROP CONSTRAINT UC_Person;

MySQL:

ALTER TABLE Persons

DROP INDEX UC_Person;

DROP a PRIMARY KEY Constraint

To drop a PRIMARY KEY constraint, use the following SQL:

Formula

SQL Server / Oracle / MS Access:

ALTER TABLE Persons

DROP CONSTRAINT PK_Person;

MySQL:

ALTER TABLE Persons

DROP PRIMARY KEY;

DROP a FOREIGN KEY Constraint

To drop a FOREIGN KEY constraint, use the following SQL:

Formula

SQL Server / Oracle / MS Access:

ALTER TABLE Orders

DROP CONSTRAINT FK_PersonOrder;

MySQL:

ALTER TABLE Orders

DROP FOREIGN KEY FK_PersonOrder;

DROP a CHECK Constraint

To drop a CHECK constraint, use the following SQL:

Formula

SQL Server / Oracle / MS Access:

ALTER TABLE Persons

DROP CONSTRAINT CHK_PersonAge;

MySQL:

ALTER TABLE Persons

DROP CHECK CHK_PersonAge;

Drop Default

Previous

SQL SELECT DISTINCT Keyword

Next

SQL DROP COLUMN Keyword