gpt4 book ai didi

sql - 回滚已提交的事务

转载 作者:行者123 更新时间:2023-12-04 00:09:47 27 4
gpt4 key购买 nike

有什么方法可以在rollback中执行oracle 11g提交的事务

我在db中做了一个delete from table并提交了它,现在我想rollback提交更改。有什么办法吗?

最佳答案

您无法回滚已提交的内容。在这种特定情况下,作为最快的选项之一,您可以做的是对已从中删除行并将其插入的表进行闪回查询。这是一个简单的示例:

注意:此操作的成功取决于undo_retention参数的值(默认为900秒)-一段时间(可以自动减少),在此期间撤消信息将保留在撤消表空间中。

/* our test table */
create table test_tb(
col number
);
/* populate test table with some sample data */
insert into test_tb(col)
select level
from dual
connect by level <= 2;

select * from test_tb;

COL
----------
1
2
/* delete everything from the test table */
delete from test_tb;

select * from test_tb;

no rows selected


向后插入已删除的行:

/* flashback query to see contents of the test table 
as of specific point in time in the past */
select * /* specify past time */
from test_tb as of timestamp timestamp '2013-11-08 10:54:00'

COL
----------
1
2
/* insert deleted rows */
insert into test_tb
select * /* specify past time */
from test_tb as of timestamp timestamp '2013-11-08 10:54:00'
minus
select *
from test_tb


select *
from test_tb;

COL
----------
1
2

关于sql - 回滚已提交的事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19853150/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com