Truncate vs Delete in DataBase Table

By Santhosh N

This explains the major differences between Truncate and Delete statements in Databases like Oracle, SQL Server.

Following are the major differences between Truncate and Delete statements:

1) Once you issue TRUNCATE statement, it cannot be rolled back where as DELETE statement has the option of rollback.
2) TRUNCATE resets the identity of the table where as DELETE does not reset the same.
3) TRUNCATE is a DDL Command where as DELETE is a DML Command.
4) One could not issue TRUNCATE statement on a table referenced by a Foreign Key constraint where as DELETE statement can be issues to the table referenced by a Foreign Key constraint.
5) TRUNCATE statement executes faster and uses less resources of transaction log where as DELETE statement is slow as it deletes rows one by one and for each record an entry is made in transaction log thereby increasing resources.
6) TRUNCATE statement removes the data and deallocates the data pages used to store the table’s data where as DELETE statement does not remove data pages and identity counters remain.
7) TRUNCATE removes all the rows of the table but not the table structure, columns, constraints, indexes. We could use WHERE clause in DELETE but not in TRUNCATE statement.
8) TRUNCATE statement could not activate triggers where as DELETE statement could activate triggers.

Related FAQs

This explains the differences between Primary Key and Unique key in the Table of Databases like Oracle, SQL Server, etc...
This explains about the maximum number of parameters allowed in Stored Procedures and functions in SQL Server 2008 R2.
This explains about the limitation of the number of columns allowed in the SELECT, INSERT and UPDATE Queries in the SQL Server.
This explains the maximum number of columns allowed for keys (Primary, index and foreign keys) in SQL Server.
This explains the maximum size in bytes that is allowed for keys (Primary, index and foreign keys) in SQL Server.
This explains the maximum size of the STRING Data type Columns’ value allowed by the SQL Server.
Truncate vs Delete in DataBase Table  (1204 Views)