Oracle Flashback

     Oracle独有的闪回特性,帮助DBA在特定情况下快速恢复数据(无需从备份中还原),相关操作以及限制汇总整理如下:

      1、flashback table schema1.table1 to before drop  --闪回删除,使用回收站功能,sys拥有的table不支持

      2、flashback database to scn/timestamp/restore point --闪回数据库,需启用闪回日志和归档模式,mount状态执行,物理介质损耗、控制文件被还原或者重建时不支持闪回

      3、flashback table schema1.table1 to scn/timestamp   --闪回表,需启用表的行移动,undo数据没有被覆盖

        alter table schema1.table1 enable row movement;

        flashback table schema1.table1 to timestamp to_timestamp('2013/06/23 19:17:00','yyyy/mm/dd hh24:mi:ss');

       flashback table schema1.table1 to scn 1938576

      4、select *  schema1.table1 as of scn/timestamp   --闪回查询,undo数据没有被覆盖

      5、   select versions_xid,versions_operation,versions_starttime,versions_endtime from schema1.table1 versions  between  timestamp/scn  minvalue  and       maxvalue

order by versions_xid,versions_endtime --闪回版本查询,undo数据没有被覆盖

 

      6、select * from flashback_transaction_query  --闪回事物查询,undo数据没有被覆盖

 

       7、declare

     xids sys.xid_array;

    begin

     xids := sys.xid_array('xid');

     dbms_flashback.transaction_backout(1,xids,options=>dbms_flashback.cascade);

    end;

    /

commit; --闪回事物,要求是在归档模式且启用附加日志,需注意事物依赖性

 

      8、create flashback archive fla1 tablespace fda1 retention 2 year;

         alter table t1 flashback archive fla1;

         select *  t1 as of scn/timestamp    --闪回数据归档 ,将undo数据保存至表空间避免被覆盖

 

 

posted @ 2022-12-15 14:20  踏雪无痕2017  阅读(198)  评论(0)    收藏  举报