SQLancer
LESSON 18

SQL (Core) - Dropping tables

Progress: 0%

SQL Lesson 18: Dropping tables

When an entire database table and all its stored records are permanently retired, you remove the object using the DROP TABLE query.

1. Safe Drop Syntax

Always include the IF EXISTS clause to prevent runtime migration failures if the table has already been removed:

DROP TABLE IF EXISTS old_movies;

2. DROP vs. TRUNCATE vs. DELETE

  • DELETE FROM table: Removes rows individually; schema structure remains.
  • TRUNCATE TABLE: Instantly wipes all rows while preserving schema structure.
  • DROP TABLE: Destroys both all stored data rows and the schema definition itself.
🚨

Irreversible Action

Executing DROP TABLE immediately deletes the schema and all records. Always double-check database connection strings and environment variables before dropping production tables!

🗄️ Schema Explorer SELECTABLE

movies
|

🎯 Exercises Checklist:

1. Drop the Boxoffice table if it exists
2. Drop the Buildings table if it exists
⚡ Practice Console

Data Output

No results. Run query to fetch data.

Current Task Target

5 rows