The MySQL DROP TABLE statement deletes both the table's row data and its entire schema definition from the database. By contrast, TRUNCATE TABLE empties every row quickly while keeping the table columns and indexes intact.
| Command | Removes Rows | Removes Schema | Resets AUTO_INCREMENT | Can Rollback |
|---|---|---|---|---|
DROP TABLE |
Yes | Yes | N/A (table gone) | No (DDL) |
TRUNCATE TABLE |
Yes | No | Yes (resets to 1) | No (DDL) |
DELETE FROM |
Filtered/All | No | No | Yes (DML) |
Use IF EXISTS when cleaning up staging or temporary tables, and verify foreign key dependents before running DDL on shared schemas:
-- Drop a staging table only if it exists
DROP TABLE IF EXISTS demo_staging_orders;
-- Empty a test table fast and reset AUTO_INCREMENT
TRUNCATE TABLE demo_import_logs;
TRUNCATE or DROP: MySQL blocks DROP TABLE and TRUNCATE TABLE on a parent table (like demo_customers) whenever a child table (like demo_orders) references it via a foreign key. Drop or truncate the child table first instead of blindly disabling FOREIGN_KEY_CHECKS.DROP TABLE and TRUNCATE TABLE are DDL statements that automatically commit any open transaction right before executing.information_schema.KEY_COLUMN_USAGE to locate views or foreign keys referencing a table before removing it.TRUNCATE TABLE much faster than DELETE FROM?DELETE FROM scans and logs every single row individually in the undo log, whereas TRUNCATE TABLE drops and recreates the table data file in constant time.
Yes, DROP TABLE IF EXISTS demo_temp_a, demo_temp_b; removes multiple tables atomically in one command.
DROP TABLE delete views that query that table?No, the view definition stays behind, though querying that view afterward raises an invalid-view error until repaired or dropped.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.