SQL > Data Definition Language (DDL) > Drop Table Statement

Sometimes we may decide that we need to get rid of a table in the database. In fact, it would be problematic if we cannot do so because this could create a maintenance nightmare for the DBA's. Fortunately, SQL allows us to do it, as we can use the DROP TABLE command.

SQL DROP TABLE permanently deletes a table and all its data from the database — this action cannot be undone. Use IF EXISTS to avoid errors when dropping tables that may not exist.

The syntax for DROP TABLE is,

DROP TABLE "table_name";

If we wanted to drop the Customer table that we created in the CREATE TABLE section, we simply type,

DROP TABLE Customer;

Be careful when you use this command, as the table and any data stored in that table will be lost!

Drop Multiple Tables At The Same Time

It is possible to drop more than one table at a time. To do that, list the names of all the tables we wish to drop separated by comma after DROP TABLE. For example, if we want to drop the User_Details table and the Job_List table together, we can issue the following SQL statement:

DROP TABLE User_Details, Job_List;

IF EXISTS

When we attempt to drop a table that does not exist, an error will result. To prevent this type of error from happening, some databases such as MySQL and Oracle allow an optional "IF EXISTS" phrase between DROP TABLE and the table name(s). This tells the database to execute the DROP TABLE statement only if the table to be dropped already exists. If the table does not exist, nothing is executed and there is no error message. The following is an example of a DROP TABLE IF EXISTS statement:

DROP TABLE IF EXISTS Customer;

Frequently Asked Questions

What does SQL DROP TABLE do?
SQL DROP TABLE permanently removes a table and all the data it contains from the database. This action cannot be undone, so it should be used with caution.
What is the difference between DROP TABLE and TRUNCATE TABLE?
DROP TABLE removes the table structure and all its data permanently. TRUNCATE TABLE removes all rows from the table but keeps the table structure intact, so you can still insert data into it afterwards.
Can you drop multiple tables at once in SQL?
Yes. List the table names separated by commas after DROP TABLE. For example: DROP TABLE table1, table2; will remove both tables in one statement.
What does DROP TABLE IF EXISTS do?
DROP TABLE IF EXISTS tells the database to drop the table only if it already exists. If the table does not exist, no error is raised and nothing happens. This option is supported in MySQL and Oracle.

Next: SQL TRUNCATE TABLE

This page was last updated on March 19, 2026.




Copyright © 2026   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact