SQL DROP TABLE

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

SQL DROP TABLE

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which statement removes a whole table, including its structure?
A DELETE FROM students;
B DROP TABLE students;
2. After DELETE FROM products; runs with no WHERE clause, what is left?
A Nothing, the products table no longer exists
B An empty products table with its columns
3. Which is the correct syntax to drop a table called orders?
A DROP TABLE orders;
B DROP orders TABLE;
4. You run DROP TABLE results; and then SELECT * FROM results; What happens?
A An error, because the table no longer exists
B An empty result with the column headings
5. Can you reliably undo a DROP TABLE after it runs?
A No, it is permanent unless you have a backup
B Yes, the table comes back if you re-run SELECT

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1DROP TABLE orders; ARemoves every row from orders but keeps the empty table and its structure
2DELETE FROM orders; BDROP TABLE cannot use a WHERE clause because it removes the whole table. To remove only some rows, use DELETE FROM students WHERE house = 'Red';
3To remove a table that is no longer needed, including its structure and all its data, use DROP TABLE CPermanently removes the orders table, including its structure and every record in it
4A table that other tables reference through a foreign key may need those child tables dropped first DThe TABLE keyword is missing. The correct statement is DROP TABLE students;
5DROP TABLE students WHERE house = 'Red'; EDROP TABLE products;
6DROP students; FDROP TABLE orders; DROP TABLE students;

Definitions

DROP TABLE

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
____ TABLE students;
2.
-- delete the subjects table completely DROP TABLE ________;
3.
-- orders has a FOREIGN KEY to students DROP TABLE ______; DROP TABLE students;
4.
______ FROM products WHERE stock = 0;
5.
-- removes the table and all its records DROP _____ products;

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A CREATE TABLE tmp (id INT);
B INSERT INTO tmp VALUES (1);
C DROP tmp;
Question 2
A DELETE TABLE orders;
B CREATE TABLE orders (
C orderId INT PRIMARY KEY,
D quantity INT
E );
Question 3
A -- Empty the table, keep it
B -- so it can be refilled later
C DROP TABLE students;
Question 4
A DROP orders TABLE;
B DROP TABLE students;
C DROP TABLE products;
Question 5
A -- Remove the child table first
B DROP TABLE FROM results;
C DROP TABLE subjects;

Answer Key

SQL DROP TABLE
Section A: Quick Questions
Q1
B — DROP TABLE students;
Q2
B — An empty products table with its columns
Q3
A — DROP TABLE orders;
Q4
A — An error, because the table no longer exists
Q5
A — No, it is permanent unless you have a backup
Section B: Match the Pairs
Q1
DROP TABLE orders; → Permanently removes the orders table, including its structure and every record in it
Q2
DELETE FROM orders; → Removes every row from orders but keeps the empty table and its structure
Q3
To remove a table that is no longer needed, including its structure and all its data, use DROP TABLE → DROP TABLE products;
Q4
A table that other tables reference through a foreign key may need those child tables dropped first → DROP TABLE orders; DROP TABLE students;
Q5
DROP TABLE students WHERE house = 'Red'; → DROP TABLE cannot use a WHERE clause because it removes the whole table. To remove only some rows, use DELETE FROM students WHERE house = 'Red';
Q6
DROP students; → The TABLE keyword is missing. The correct statement is DROP TABLE students;
Section C: Definitions
Q1
DROP TABLE — Permanently deletes a whole table, its structure and all its records. Unlike DELETE, which only removes rows, it cannot be undone and can fail if other tables reference it.
Section D: Fill in the Blanks
Q1
DROP TABLE students;
Q2
-- delete the subjects table completely DROP TABLE subjects;
Q3
-- orders has a FOREIGN KEY to students DROP TABLE orders; DROP TABLE students;
Q4
DELETE FROM products WHERE stock = 0;
Q5
-- removes the table and all its records DROP TABLE products;
Section E: Spot the Error
Q1
C — The statement is missing the TABLE keyword. To delete a whole table you must write DROP TABLE tmp;
Q2
A — DELETE TABLE is not valid SQL. DELETE only removes rows (DELETE FROM). To remove the whole table, structure and all, use DROP TABLE orders;
Q3
C — The comments say the table must be kept. DROP TABLE would destroy its structure as well as its records. DELETE FROM students; removes only the rows.
Q4
A — The keywords are in the wrong order. The correct syntax is DROP TABLE followed by the table name: DROP TABLE orders;
Q5
B — FROM belongs to DELETE FROM, not DROP TABLE. DROP TABLE takes the table name straight after it: DROP TABLE results;