What is difference between TRUNCATE and DELETE statement

Answer Posted / samba shiva reddy . m

DELETE TABLE is a logged operation, so the deletion of each
row gets logged in the transaction log, which makes it slow.
DELETE removes rows one at a time and records an entry in
the transaction log for each deleted row.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE Can be Rolled back.
DELETE is DDL command
example :
begin transaction deleteoncondition
select * from emp

Delete * from emp where empid = 1

rollback deleteoncondition
select * from emp
sp_help samba --Table structure


TRUNCATE TABLE 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.
TRUNCATE wont delete the structure of the table.

DROP will delete the structure of the table also.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I uninstall sql server 2014?

686


What are the new data types are introduced in sql 2000?

682


Explain transaction isolation levels in sql server?

761


what is create database syntax? : Sql server database administration

811


How to see existing views in ms sql server?

740


What is linked report?

104


What command do we use to rename a database?

785


What is tempdb database? : SQL Server Architecture

804


Does transparent data encryption provide encryption when transmitting data across the network?

812


What is difference between cte and view?

695


What are the steps you should follow to start sql server in single-user mode?

681


What is the use of tempdb? What values does it hold?

755


System requirements for sql server 2005 express edition?

741


Differentiate between a having clause and a where clause.

704


Mention a few common trace flags used with sql server?

689