What is the difference for delete/truncate/drop

Same:

delete/truncate/drop, all of them can support rollback/commit, the sample is as below:

begin tran T1
truncate table TestTable

rollback/commit

Difference:

delete can support where clause, but truncate/drop cannot, that is because truncate/drop is for whole table level

delete records will leave the used index there, but truncate will set up new index from 0 started

Note:

We should know that, once the transaction is committed, we cannot do rollback anymore.

By default, did any write operation, it is committed like below, so we cannot recover the lost data

delete from TestTable

If do the transaction to drop table, but don't commit it, at this time to refresh the database, it will get below error:

 

原文地址:https://www.cnblogs.com/researcher/p/4994458.html