What is difference between TRUNCATE and DELETE statement

Answer Posted / mohammed

Guys, Please remember TRUNCATE CAN BE ROLLED BACK.

DELETE TABLE is a logged operation, so the deletion of each
row gets logged in the transaction log, which makes it slow.

TRUNCATE TABLE also deletes all the rows in a table, but it
won't log the deletion of each row, instead it logs the
De-allocation of the data pages of the table, which makes it
faster.

Because TRUNCATE TABLE is not logged, it cannot activate a
trigger.
TRUNCATE can not be Rolled back using logs.
TRUNCATE is DDL Command.
TRUNCATE Resets identity of the table.

DELETE
DELETE removes rows one at a time and records an entry in
the transaction log for each deleted row.
If you want to retain the identity counter, use DELETE
instead. If you want to remove table definition and its
data, use the DROP TABLE statement.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE Can be Rolled back using logs.
DELETE is DML Command.
DELETE does not reset identity of the table.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you explain important index characteristics?

690


How to test odbc dsn connection settings?

706


How to specify the collation for a character data type in ms sql server?

740


How to remove duplicate rows from table?

835


What is the difference between a local and a global temporary table?

821






Why use stored procedures in sql server?

710


What are views in ms sql server?

786


Explain can SSRS reports Cache results?

136


Explain how to integrate the ssrs reports in application?

691


Differentiate between mongodb vs. Sql server?

786


What is DCL?

762


What are the 10 characteristics of data quality?

679


What is the difference between index seek vs. Index scan?

771


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting is possible?

677


Name 3 ways to get an accurate count of the number of records in a table?

757