What is the difference between TRUNCATE and DELETE commands?

TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause can be used with DELETE and not with TRUNCATE.

Showing Answers 1 - 10 of 10 Answers

Priyank s Pathania

  • Sep 26th, 2005
 

Both will result in deleting all the rows in the table .TRUNCATE call cannot be rolled back as it is a DDL command and all memory space for that table is released back to the server. TRUNCATE is much faster.Whereas DELETE call is an DML command and can be rolled back.

  Was this answer useful?  Yes

Sudeep Biswas

  • Nov 8th, 2006
 

TRUNCATE does not records the transactions that delete the rows from a table thus it will not be recoverable if thr transaction is rolled back.DELETE on the other hand recods the transactions and hence rows deleted can be recovered if rolled back before committing the transaction.

  Was this answer useful?  Yes

saravanan p

  • Dec 4th, 2006
 

Hi,

1. For truncate command, trigger will not get fired, but for Delete Command, Trigger will get fired.

2. Truncate Is the DDL command whereas Delete is the DML command

3.Once the truncate command is issued, Transactions can't be rolled back whereas transactions can be rolled back for Delete command.

Thanks and Regards

Saravanan P

  Was this answer useful?  Yes

SQL Sever:
Truncate:
Delete all the records from the table.
Do not keep the deleted record in the log file.
Reset the identity column to 1.
Use fewer locks with table level locking.
Tollback is not possible
Delete trigger does not gets fired
All the pages used by the table gets released
Speed is fast

Delete:
Deletes some or all records from the table depending upon the filter criteria given in where clause
Keep the deleted record in the log file
Do not reset the identity column.
Use complex locking system using row level and page level locking
Rollback is possible
Delete trigger gets fired
Empty pages may still exists in table
Speed is slow

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions