What is difference between TRUNCATE and DELETE statement

Answer Posted / shireen

TRUNCATE TABLE is functionally identical to DELETE
statement with no WHERE clause: both remove all rows in the
table. But TRUNCATE TABLE is faster and uses fewer system
and transaction log resources than DELETE.

The DELETE statement removes rows one at a time and records
an entry in the transaction log for each deleted row.
TRUNCATE TABLE removes the data by deallocating the data
pages used to store the table's data, and only the page
deallocations are recorded in the transaction log.

TRUNCATE TABLE removes all rows from a table, but the table
structure and its columns, constraints, indexes and so on
remain. The counter used by an identity for new rows is
reset to the seed for the column. 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.

You cannot use TRUNCATE TABLE on a table referenced by a
FOREIGN KEY constraint; instead, use DELETE statement
without a WHERE clause. Because TRUNCATE TABLE is not
logged, it cannot activate a trigger.

TRUNCATE TABLE may not be used on tables participating in
an indexed view.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the rdl file?

88


How retrieve field names from the table in SQL through JAVA code?

1403


What is transaction server implicit?

535


Define inner join in sql server joins?

535


What is a transactions?

606






What is order of B+tree?

663


What is a unique key constraint?

537


what does the automatic recovery do? : Sql server administration

540


What is the maximum row of a size?

577


What is the difference between left and right outer join?

547


How do I schedule a sql server profiler trace?

540


How to modify an existing user defined function?

603


How to generate create function script on an existing function?

596


What are the components of dbms?

535


How can I create a new template for import ? : sql server management studio

603