| Documentation

DROP TABLE

The DROP TABLE statement is used to remove an existing table in a database. You can remove one or more tables with a single DROP TABLE statement.

Syntax

The basic syntax for the DROP TABLE statement is:

DROP TABLE table_name;

To drop more than one table, use the following syntax:

DROP TABLE table_name1, table_name2, table_name3;

Parameters

Optional Clauses (Database Specific)

Some database systems offer additional clauses for more control:

IF EXISTS

The IF EXISTS clause prevents an error if the table does not exist. It will simply do nothing if the table is not found.

DROP TABLE IF EXISTS table_name;

Note: Support for IF EXISTS varies across different SQL database systems (e.g., MySQL, PostgreSQL support it; SQL Server requires a different approach like checking system catalogs).

Examples

Example 1: Dropping a single table

This example shows how to drop a table named Customers:

DROP TABLE Customers;

Example 2: Dropping multiple tables

This example drops two tables, Orders and Products:

DROP TABLE Orders, Products;

Example 3: Dropping a table if it exists (MySQL/PostgreSQL)

This is a safer way to drop a table, avoiding errors if it's already gone:

DROP TABLE IF EXISTS Employees;

Important Considerations

Database Specific Notes

While the basic syntax is standard SQL, some database systems have nuances:

Related Topics