Tuesday, January 7, 2025
HomeProgrammingDifference between DELETE and TRUNCATE

Difference between DELETE and TRUNCATE

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.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x