ITPub博客

首页 > 数据库 > Oracle > 循序渐进oracle,第10章笔记-闪回

循序渐进oracle,第10章笔记-闪回

Oracle 作者:pooldb 时间:2015-01-16 10:14:34 0 删除 编辑

1)闪回时间点查询
select count(*) from eygle as of timestamp (timestamo - interval'10'second);

2)获得当前SCN
select dbms_flashback.get_system_change_number scn from dual;

3)闪回SCN查询
select count(*) from eygle as of scn 1895690000;

4)查看数据库SCN变化
select name,first_change# fscn,next_change# nscn,first_time from v$archived_log;

5)查看大概时间点对应得SCN号
 select * from (select * from smon_scn_time order time_mp desc) where rownum<2;


6)将SCN转换为时间戳
select scn_to_timestamp(8908390522972) scn from dual;

7)时间戳转化为SCN
select timestamp_to_scn(scn_to_timestamp(8908390522972)) scn from dual;

8)查询最小的能转换的SCN

select scn_wrp*4294967296 + SCN_bas scn from smon_scn_time
where time_mp = (select min(time_mp) from smon_scn_time);

9)查询最小的能转换的SCN时间戳
select thread,time_mp,time_dp,scn_wrp,scn_bas,scn_wrp*65536*65536+scn_bas scn
from smon_scn_time
where time_mp = (select min(time_mp) from smon_scn_time);

10)闪回数据库开启(mount状态)
alter database flashback on;

11)c闪讯数据库的闪回状态
select dbid,name,flashback_on,current_scn
from v$database;

12)
db_falshback_retention_target用于定义闪回最大时间上限

13)
闪回数据库需要在mount状态下
flashback database to timetamp
to_timestamp('2007-03-10 13:41:52','yyyy-mm-dd hh24:mi:ss');

14)查看回收站
show recyclebin;

flashback table t1 to before drop;

15)闪回版本查询你
select versions_starttime,versions_endtime,versions_xid,versions_operation,
username,user_id
from t versions between timestamp minvalue and maxvalue;

16)恢复事物
select undo_sql frm flashback_transaction_query
where xid = hextoraw('sXID');

17)闪回表
flashback table test to scn 1030688;

18)创建闪回数据归档
create table space fbra datafile size 200M
segment space management auto;

create flashback archive dataarchive tablespace fbra retention 1 month;


19)开启对表的闪回归档
alter table eygle flashback archive dataarchive;
alter table eygle no flashback archive dataarchive;

20)alter system dump datafile 4 block 204;生成对应跟踪文件

21)
通过ora_rowscn闪回
select web_id,ora_rowscn from cms_web_ext where web_id=13733;
select web_id,ora_rowscn,scn_to_timestamp(ora_rowscn) from cms_web_ext where web_id=13733;














来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30074459/viewspace-1403796/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-12-22

  • 博文量
    404
  • 访问量
    296521