BBampaa

Lessons › SQL › Deep Dive: Database Admin & ETL

SQL lesson

DROP TABLE

DROP TABLE permanently deletes an entire table from the database - not just the rows inside it, but the structure itself.

Try this lesson free →
About 5–10 minutes · no sign-up needed

Example

Removing an Unneeded Retail Table with DROP TABLE

DROP TABLE IF EXISTS returns_staging

Result:

Step by step

  1. DROP TABLE removes the table and all its rows. There's no undo.
    DROP TABLE returns_staging;
  2. IF EXISTS makes the statement safe to run even if the table isn't there - no error.
    DROP TABLE IF EXISTS returns_staging;
  3. CASCADE also drops anything that depends on the table (views, foreign keys).
    DROP TABLE IF EXISTS returns_staging CASCADE;

Practice

Try each one in your head first, then open the answer.

1. Write a statement to delete the products table entirely from the database.
DROP TABLE products
2. Write a statement to delete the customers table entirely from the database.
DROP TABLE customers
3. Write a statement to delete the orders table entirely from the database.
DROP TABLE orders
4. Write a statement to delete the inventory table entirely from the database.
DROP TABLE inventory
5. Write a statement to delete the suppliers table entirely from the database.
DROP TABLE suppliers

Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.

Try this lesson free →
About 5–10 minutes · no sign-up needed