What is the difference between DELETE, TRUNCATE and DROP?
| Command | Removes | WHERE? | Can be rolled back? |
|---|---|---|---|
DELETE | Chosen rows | Yes | Yes, inside a transaction |
TRUNCATE | All rows, table stays. Counter restarts | No | No |
DROP | The table (structure and data) | No | No |
DELETE FROM students WHERE id = 6;
TRUNCATE TABLE students;
DROP TABLE students;
TRUNCATE is faster than DELETE without WHERE. See DELETE and DROP TABLE.
Learn more about the similar topics:
| Tutorials |
|---|
| MySQL INSERT INTO |
| MySQL UPDATE Query |
| MySQL DELETE Query |
| Interview Questions & Answers |
|---|
| What is the difference between DELETE, TRUNCATE and DROP? |