What is DROP TABLE?
DROP TABLE deletes the entire table - structure and all data. Gone forever!
The Syntax
DROP TABLE table_name;Example
DROP TABLE old_students;After this, the old_students table no longer exists.
Safe Version: IF EXISTS
Use this to avoid errors if table doesn't exist:
DROP TABLE IF EXISTS old_students;ALTER TABLE vs DROP TABLE
ALTER TABLE - Changes the table (add/remove columns)
ALTER TABLE students DROP COLUMN age;
-- Table still exists, just without the age columnDROP TABLE - Deletes the entire table
DROP TABLE students;
-- Table is completely gone!Think of it this way:
- ALTER = Renovate a house (change rooms)
- DROP = Demolish the house (remove everything)
DELETE vs DROP
DELETE - Removes data, keeps table
DELETE FROM students;
-- Table is empty but still existsDROP - Removes table completely
DROP TABLE students;
-- Table doesn't exist anymoreHow DROP TABLE Works (Step by Step)
Step 1: Write DROP TABLE command
Step 2: Specify which table to delete
Step 3: Add semicolon ;
Step 4: Table is gone!
DROP TABLE old_data; -- Steps 1, 2, 3 → Table deleted!When to Use DROP TABLE?
- Removing test tables you don't need
- Cleaning up old backup tables
- Starting fresh with a new table design
Warning: DROP TABLE is permanent! Always backup important data first.