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
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 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 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
Delete and Truncate command has some differences. The differences between Delete and Truncate are given bellow:
Delete
- It is slow
- It keeps log for every row
- We can use where clause
- It delete all data based on where clause
Truncate
- It is faster
- It does not keeps log
- We can’t use where clause
- 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.
No comments