create table tmp_insert_in_txn ( something int not null primary key )
begin transaction
select 1 as something into tmp_created_in_txn
-- show the value was inserted
select something as in_txn from tmp_created_in_txn
insert into tmp_insert_in_txn with ( tablock )
( something )
select something from tmp_created_in_txn
-- show the value was inserted
select something as in_txn from tmp_insert_in_txn
rollback
-- no rows after rollback:
select * from tmp_insert_in_txn
-- no table after rollback:
select * from tmp_created_in_txn
是的。
我决定在这里问只是非常懒惰所以自己测试了。
这表明回滚确实删除了表 tmp_test 和 tmp_test2 中的行,因此答案是最少记录的操作仍会回滚。
嗯...那么使用它们如何防止事务日志变得非常大呢?