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 @   踏雪无痕2017  阅读(183)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2021-12-15 Sql Server query store
2021-12-15 HammerDB 进行数据库压力测试
2021-12-15 NMON 介绍、使用
点击右上角即可分享
微信分享提示