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 →Example
Removing an Unneeded Retail Table with DROP TABLE
DROP TABLE IF EXISTS returns_stagingStep by step
- DROP TABLE removes the table and all its rows. There's no undo.
DROP TABLE returns_staging; - IF EXISTS makes the statement safe to run even if the table isn't there - no error.
DROP TABLE IF EXISTS returns_staging; - CASCADE also drops anything that depends on the table (views, foreign keys).
DROP TABLE IF EXISTS returns_staging CASCADE;
Practice
1. Write a statement to delete the products table entirely from the database.
DROP TABLE products2. Write a statement to delete the customers table entirely from the database.
DROP TABLE customers3. Write a statement to delete the orders table entirely from the database.
DROP TABLE orders4. Write a statement to delete the inventory table entirely from the database.
DROP TABLE inventory5. Write a statement to delete the suppliers table entirely from the database.
DROP TABLE suppliersLearn 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 →