SQL Keyword - DROP

DROP Keyword

The Drop keyword is used to delete existing tables, databases, views, indexes, etc.

The Drop keyword is also used to delete an existing column or constraints from a table.

DROP DATABASE

The Drop Database keyword is used to delete an existing database in SQL.

Syntax

DROP DATABASE <DATABASE_NAME>;

Example

DROP DATABASE MyDB;

DROP TABLE

The Drop Table keyword is used to delete an existing table from a database.

Syntax

DROP TABLE <TABLE_NAME>;

Example 

DROP TABLE Employee;

DROP VIEW

The Drop View keyword is used to delete an existing view from a database.

Syntax

DROP VIEW <VIEW_NAME>;

Example

DROP VIEW Employee_Male_V;

DROP INDEX

The Drop Index keyword is used to delete an index in a table.

Syntax

DROP INDEX <TABLE_NAME.INDEX_NAME>;

Example

DROP INDEX Employee.My_Index;

DROP COLUMN

The Drop Column keyword is used to delete a column in an existing table.

Syntax

ALTER TABLE <TABLE_NAME> DROP COLUMN <COLUMN_NAME>;

Example

ALTER TABLE Employee DROP COLUMN Emp_Gender;

DROP CONSTRAINT

The Drop Constraint keyword is used to delete a constraint in an existing table.

Syntax

ALTER TABLE <TABLE_NAME> DROP CONSTRAINT <CONSTRAINT_NAME>;

Example

ALTER TABLE Employee DROP CONSTRAINT Chk_EmpAge;

Summary

The Drop keyword is used to delete something in SQL like a database, table, view, index, or also delete a column or constraint from a table.