The difference between DELETE and TRUNCATE in SQL:
- DELETE: Removes specific rows based on a condition. It is slower, logs individual row deletions, and can be rolled back. Syntax:
DELETE FROM table_name WHERE condition;
- TRUNCATE: Removes all rows from a table. It is faster, minimal logging, and cannot be rolled back in most cases. Syntax:
TRUNCATE TABLE table_name;
Use DELETE for selective deletions and TRUNCATE for clearing entire tables.