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 to define and use table alias names in ms sql server?

561


How to execute a stored procedure in ms sql server?

549


What are the advantages of mirroring?

571


How important do you consider cursors or while loops for a transactional database?

529


what is a check constraint?

638






What stored procedure can you use to display the current processes?

492


What is the difference between varchar and varchar(max) datatypes?

553


What is extent? Types of extents?

587


Explain how would you store your query in an SSRS report or a Database server?

90


System variable and temporary variables

1707


Write a program to fetch first 10 records from a file?

602


How do I create an extended event in sql server?

485


What are the 10 characteristics of data quality?

527


What are different replication agents and what's their purpose? : sql server replication

570


What is a filestream?

554