MySQL DROP TABLE Statement
MySQL DROP TABLE Statement
The DROP TABLE statement in MySQL is used to permanently delete an existing table from a database, along with all its data, indexes, and relationships.
⚠️ Warning: This action is irreversible. All data in the table will be lost.
🔹 Syntax
-
table_name→ Name of the table to delete
🔹 Syntax with IF EXISTS
-
Prevents an error if the table does not exist
🔹 Example 1: Delete a Table
-
Deletes the table
Studentspermanently.
🔹 Example 2: Delete Table If Exists
-
Deletes
Studentsonly if it exists; otherwise, no error occurs.
🔹 Deleting Multiple Tables
-
Deletes multiple tables at once
🔹 Key Points
-
DROP TABLE deletes everything: data, indexes, triggers, and table structure.
-
Always use IF EXISTS to avoid runtime errors.
-
After dropping a table, it cannot be recovered unless you have a backup.
-
Use
SHOW TABLES;to check existing tables before dropping.
💡 Tip: Combine with SHOW TABLES; to verify tables before dropping:
