Difference between Delete and Truncate

Both Delete and Truncate is SQL command used to delete records from the table. Their functionalities are almost same, but have some difference which can arise confusion. This article describes the difference between Delete and Truncate command. Summary of the article:

  • What is Delete Command?
  • What is Delete Truncate ?
  • Delete VS Truncate

sql

What is Delete Command?
Delete is a SQL command that is used to delete records from the table in a database. A sample example of SQL Delete command is given bellow:

DELETE FROM Marks
WHERE	ID=2

What is Truncate Command?
Truncate is a SQL command that is used to delete records from the table in a database. A sample example of SQL Truncate command is given bellow:

TRUNCATE TABLE Marks

Delete VS Truncate
Delete and Truncate command has some differences. The differences between Delete and Truncate are given bellow:
Delete

  1. It is slow
  2. It keeps log for every row
  3. We can use where clause
  4. It delete all data based on where clause

Truncate

  1. It is faster
  2. It does not keeps log
  3. We can’t use where clause
  4. It delete all data

So, don’t be confused on Delete and Truncate. One should have clear concept on SQL commands. Unless it may arise problems.

Leave a Reply

Your email address will not be published. Required fields are marked *