Drop table command in SQL

The DROP TABLE command in SQL is used to delete an existing table structure and all its data from the database. This action is irreversible, meaning once the table is dropped, the data cannot be recovered unless we have a backup.

SQL Syntax

DROP TABLE [IF EXISTS] [database_name.][schema_name.]table_name;

The parameters inside the [] are the optional parameters.

Example: To drop a table named employees:

SQL

DROP TABLE employees;

Examples with Variations • Dropping multiple tables:

SQL

DROP TABLE employees, departments, salaries;

• If the table might not exist (to avoid an error):

SQL

DROP TABLE IF EXISTS employees;