← QCE Digital Solutions Unit 4

SQL DROP TABLE

DROP TABLE name; permanently deletes a whole table and all its records. It cannot be undone. Add IF EXISTS to avoid an error when the table is missing.

Understanding SQL DROP TABLE in QCE Digital Solutions Unit 4

What it does: DROP TABLE permanently deletes the table and all its records. There is no undo, so back up first. Adding IF EXISTS makes the statement safe to run whether or not the products table is there. DROP TABLE is permanent. Unless you have a backup, the table and its data are gone, so check carefully before you run it. DROP TABLE removes the entire table. To remove one record, use DELETE FROM with a WHERE condition. IF EXISTS stops SQL from raising an error when the named table is not in the database. The correct syntax is DROP TABLE followed by the table name. DROP alone is not valid here.

Common mistakes: The keyword is spelled EXISTS, with an S. It should be DROP TABLE IF EXISTS old_log; so the statement does not error if the table is missing. SQL has no DELETE TABLE command. A table is removed with DROP TABLE, so the line should be DROP TABLE IF EXISTS temp;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 127–333) and word search (Modules 127–401).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which statement removes the whole table named orders, including its structure?
DROP TABLE orders;DELETE FROM orders;
Matches
DROP students;
↓
The TABLE keyword is missing. It must be DROP TABLE students; to say that a table is being removed.
Applying
Meanings
Term
DROP TABLE
Meaning
DROP TABLE name; permanently deletes a whole table and all its records. It cannot be undone. Add IF EXISTS to avoid an error when the table is missing.
Practice
DROP TABLE IF EXISTS orders;
Testing
Gaps
TABLE students;
Check Answer
Spots
1-- remove the old log table
2DROP TABLE IF EXIST old_log;

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Chambered Nautilus' badge — File Explorer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which statement removes the whole table named orders, including its structure?
A. DROP TABLE orders; ✓
B. DELETE FROM orders;
DROP TABLE removes the table itself and all its records. DELETE FROM only removes the rows and leaves the empty table behind.
2. After DROP TABLE students; runs, can you get the records back with an undo command?
A. No, the data cannot be recovered ✓
B. Yes, run UNDO DROP to restore it
DROP TABLE is permanent. Unless you have a backup, the table and its data are gone, so check carefully before you run it.
3. Which version avoids an error if the table results does not exist?
A. DROP TABLE results IF EXISTS;
B. DROP TABLE IF EXISTS results; ✓
IF EXISTS goes straight after DROP TABLE and before the table name. The statement then does nothing if the table is missing.
4. What happens when you run DROP TABLE tempData; and tempData does not exist (no IF EXISTS)?
A. The database reports an error ✓
B. It quietly creates an empty tempData table
Without IF EXISTS, dropping a missing table causes an error. Adding IF EXISTS prevents that error.
5. Which statement is correct SQL for dropping a table?
A. DROP products TABLE;
B. DROP TABLE products; ✓
The keywords come first, in the order DROP TABLE, followed by the table name and a semicolon.

Match the Pairs

DROP TABLE orders; → Permanently removes the whole orders table, including its structure and every record in it
DROP TABLE IF EXISTS results; → Drops the results table only if it exists, so there is no error when the table is missing
A dropped table cannot be recovered, so the whole table and its records are gone for good → DROP TABLE students;
Remove a table safely in a setup script so it runs without an error even if the table was never created → DROP TABLE IF EXISTS products;
DROP students; → The TABLE keyword is missing. It must be DROP TABLE students; to say that a table is being removed.
DROP TABLE students; -- only to remove old rows → DROP TABLE deletes the whole table, not just old rows. Use DELETE FROM with a WHERE condition to remove only some records.

Key Term

DROP TABLE
DROP TABLE name; permanently deletes a whole table and all its records. It cannot be undone. Add IF EXISTS to avoid an error when the table is missing.

Fill in the Blanks

1. DROP TABLE students;
Hint: Type the SQL keyword that permanently removes something from the database.
2. DROP TABLE results;
Hint: Type the keyword that says what kind of database object is being removed.
3. DROP TABLE IF EXISTS orders;
Hint: Type the word that starts the safety clause, which stops an error if the table is missing.
4. DROP TABLE orders; DROP TABLE products;
Hint: Type the table that holds a foreign key to products and records purchases. It must be dropped first.
5. DROP TABLE IF EXISTS subjects;
Hint: Type the keyword that checks the table is present before dropping it.

Spot the Error

Question 1
A -- remove the old log table
B DROP TABLE IF EXIST old_log;
C SELECT * FROM students;
Line B — The keyword is spelled EXISTS, with an S. It should be DROP TABLE IF EXISTS old_log; so the statement does not error if the table is missing.
Question 2
A DELETE TABLE IF EXISTS temp;
B CREATE TABLE temp (id INT);
C INSERT INTO temp VALUES (1);
Line A — SQL has no DELETE TABLE command. A table is removed with DROP TABLE, so the line should be DROP TABLE IF EXISTS temp;
Question 3
A -- remove the unused table
B DROP old_notes;
C SELECT * FROM students;
Line B — DROP must be followed by the word TABLE and then the table name. The line should be DROP TABLE old_notes;
Question 4
A DROP TABLE archive IF EXISTS;
B CREATE TABLE archive (id INT);
C SELECT * FROM students;
Line A — IF EXISTS comes before the table name, not after it. The correct line is DROP TABLE IF EXISTS archive;
Question 5
A CREATE TABLE temp (id INT);
B INSERT INTO temp VALUES (1);
C SELECT * FROM temp;
D DROP TABLE temp WHERE id = 1;
Line D — DROP TABLE removes the whole table, so it cannot take a WHERE condition. Use DELETE FROM temp WHERE id = 1; to remove single rows, or DROP TABLE temp; to remove the table.

Student with a class code? Join your class →