回滚已提交的事务

Var*_*run 12 sql oracle oracle11g

有没有办法在oracle 11g中回滚已提交的事务

我已经从db中删除了表并提交了它,现在我想回滚已提交的更改.有什么办法吗?

Nic*_*nov 29

您无法回滚已经提交的内容.在这种特殊情况下,作为最快的选项之一,您可以执行的操作是针对已删除行的表发出闪回查询并将其插回.这是一个简单的例子:

注意:此操作的成功取决于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
Run Code Online (Sandbox Code Playgroud)

插入已删除的行:

/* 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
Run Code Online (Sandbox Code Playgroud)

  • 另一种方法是使用 FLASHBACK TABLE - 这听起来相似但完全不同:http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9012.htm (2认同)