My question is kind of easy but i'm still doubting after I created this transaction. If I execute the following code:
我的问题很简单,但在创建此交易后我仍然怀疑。如果我执行以下代码:
BEGIN TRANSACTION
DROP TABLE Table_Name
Can I perform a ROLLBACK TRANSACTION that recovers the dropped table? I'm asking because I don't know what happens in the 'Object Explorer' and I didn't found any question of this topic, so I think that it could be a useful issue.
我可以执行恢复删除表的ROLLBACK TRANSACTION吗?我问,因为我不知道'对象资源管理器'中发生了什么,我没有发现任何关于这个主题的问题,所以我认为这可能是一个有用的问题。
3 个解决方案
#1
11
DROP TABLE
can be rolled back and it does not auto-commit.
DROP TABLE可以回滚,也不会自动提交。
#2
14
This is incredibly easy to test.
这非常容易测试。
create table TransactionTest
(
ID int identity primary key clustered,
SomeValue varchar(20)
)
insert TransactionTest
select 'Here is a row'
begin transaction
drop table TransactionTest
rollback transaction
select * from TransactionTest
#3
2
I just want to add that I tried in Oracle 11g, Mysql 5.7 and MSSQL 2016. It only rolled back (worked) with MSSQL RDBMS. I would expect that most other RDBMS won't support it since it execute schema changes.
我只想补充一点,我在Oracle 11g,Mysql 5.7和MSSQL 2016中尝试过。它只用MSSQL RDBMS回滚(工作)。我希望大多数其他RDBMS不会支持它,因为它执行架构更改。
ORACLE PL/SQL EX:
ORACLE PL / SQL EX:
savepoint mysave;
DROP TABLE test_table;
ROLLBACK TO mysave;
select * from test_table;
#1
11
DROP TABLE
can be rolled back and it does not auto-commit.
DROP TABLE可以回滚,也不会自动提交。
#2
14
This is incredibly easy to test.
这非常容易测试。
create table TransactionTest
(
ID int identity primary key clustered,
SomeValue varchar(20)
)
insert TransactionTest
select 'Here is a row'
begin transaction
drop table TransactionTest
rollback transaction
select * from TransactionTest
#3
2
I just want to add that I tried in Oracle 11g, Mysql 5.7 and MSSQL 2016. It only rolled back (worked) with MSSQL RDBMS. I would expect that most other RDBMS won't support it since it execute schema changes.
我只想补充一点,我在Oracle 11g,Mysql 5.7和MSSQL 2016中尝试过。它只用MSSQL RDBMS回滚(工作)。我希望大多数其他RDBMS不会支持它,因为它执行架构更改。
ORACLE PL/SQL EX:
ORACLE PL / SQL EX:
savepoint mysave;
DROP TABLE test_table;
ROLLBACK TO mysave;
select * from test_table;