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
How to add a new dsn with the odbc driver for sql server?
What is a non equi join?
How much is a sql server license?
How to declare and use cursor variables?
Define Wed Edition in SQL Azure?
How optimize sql query with multiple joins in sql server?
What is the Main Difference between ACCESS and SQL SERVER?
What are sub reports and how to create them?
How can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role?
What is mean by clustered index and non clustered index, give syntax of creation? : sql server database administration
Can you change the data type of a column in a table after the table has been created? If so, which command would you use?
How do I view a stored procedure in sql server query?
What is pivot and unpivot?
What is stretch database in sql server?
How to modify existing triggers using "alter trigger"?