Concept Flow - DROP and TRUNCATE behavior
Start
Choose Operation
DROP Table
Remove Table
Table Gone
End
You start by choosing DROP or TRUNCATE. DROP removes the whole table and its data. TRUNCATE deletes all rows but keeps the table structure.
DROP TABLE employees; -- removes the entire employees table TRUNCATE TABLE employees; -- deletes all rows but keeps the table structure
| Scenario | Step | Operation | Action | Table Exists? | Data Exists? |
|---|---|---|---|---|---|
| DROP | 1 | DROP TABLE employees; | Removes table and data | No | No |
| DROP | 2 | Check table after DROP | Table is gone | No | No |
| TRUNCATE | 3 | TRUNCATE TABLE employees; | Deletes all rows, keeps table | Yes | No |
| TRUNCATE | 4 | Check table after TRUNCATE | Table exists but empty | Yes | No |
| Variable | Start | After DROP | After TRUNCATE |
|---|---|---|---|
| Table Exists | Yes | No | Yes |
| Data Exists | Yes | No | No |
DROP TABLE removes the entire table and its data. TRUNCATE TABLE deletes all rows but keeps the table structure. DROP is irreversible; TRUNCATE is faster than DELETE. Use DROP to remove tables; use TRUNCATE to empty tables quickly.