oracle 记录归档日志的信息v$archived_log

v$archived_log记录的数据库所有的归档日志信息,在删除归档日志的时候不能在操作系统下面直接删除以为就可以
了,v$archived_log里面的记录还是不会变话的,要想删除归档日志必须使用rman来删除,这样oracle数据库才知道
变化,或者使用操作系统命令来删除也是可以的,但还是要使用rman来更新一下expired的日志。
SQL> select name,FIRST_CHANGE#,NEXT_CHANGE#,FIRST_TIME,NEXT_TIME from v$archived_log order by FIRST_CHANGE#;
 
NAME                                                                                       FIRST_CHANGE# NEXT_CHANGE# FIRST_TIME     NEXT_TIME
------------------------------------------------------------------------------------------ ------------- ------------ -------------- --------------
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_12/o1_mf_1_64_7gd71ovl_.arc           571247       581978 12-12-11     12-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_13/o1_mf_1_65_7ggqg1jv_.arc           581978       614556 12-12-11     13-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_14/o1_mf_1_66_7gkc38o7_.arc           614556       643449 13-12-11     14-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_67_7gm6jolr_.arc           643449       653614 14-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_68_7gmhy80o_.arc           653614       660659 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_69_7gmj3zwo_.arc           660659       660742 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_70_7gmk6z3c_.arc           660742       661427 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_71_7gmk7nts_.arc           661427       661436 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_72_7gmk7vx0_.arc           661436       661442 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_73_7gmkl2v2_.arc           661442       661712 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_74_7gml7o6n_.arc           661712       662185 15-12-11     15-12-11
 
NAME                                                                                       FIRST_CHANGE# NEXT_CHANGE# FIRST_TIME     NEXT_TIME
------------------------------------------------------------------------------------------ ------------- ------------ -------------- --------------
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_75_7gml82or_.arc           662185       662193 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_76_7gml8l4q_.arc           662193       662202 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_77_7gmld1hq_.arc           662202       662312 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_78_7gmnd4js_.arc           662312       663464 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_79_7gmq9459_.arc           663464       665534 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_80_7gmqb6t5_.arc           665534       665551 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/o1_mf_1_81_7gn2ysp4_.arc           665551       678974 15-12-11     15-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_16/o1_mf_1_82_7gpd3yz0_.arc           678974       693151 15-12-11     16-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_16/o1_mf_1_83_7gplnktj_.arc           693151       699007 16-12-11     16-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_17/o1_mf_1_84_7gq077t8_.arc           699007       724489 16-12-11     17-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_17/o1_mf_1_85_7gq08vl0_.arc           724489       725831 17-12-11     17-12-11
 
NAME                                                                                       FIRST_CHANGE# NEXT_CHANGE# FIRST_TIME     NEXT_TIME
------------------------------------------------------------------------------------------ ------------- ------------ -------------- --------------
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_17/o1_mf_1_86_7grsl5ny_.arc           725831       749373 17-12-11     17-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_17/o1_mf_1_87_7gsfr592_.arc           749373       772081 17-12-11     17-12-11
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_18/o1_mf_1_88_7gvp82pf_.arc           772081       787226 17-12-11     18-12-11
 
已选择25行。

FIRST_CHANGE#  开始scn号
NEXT_CHANGE#  借宿scn号
FIRST_TIME     开始时间
NEXT_TIME     结束时间


下面记录一个利用scn来闪回恢复数据的实验:
首先用户误删除一个表的数据,只记得一个大概的时间点:2011-12-18 20:20;25
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi;ss') from dual;
 
TO_CHAR(SYSDATE,'YY
-------------------
2011-12-18 20:20;25
 
SQL> select count(*) from t1;
 
  COUNT(*)
----------
      9999
 
SQL> delete from t1 where rownum < 100;
 
已删除99行。
 
SQL> commit;
 
提交完成。
 
SQL> select count(*) from t1;
 
  COUNT(*)
----------
      9900




接下来利用这个时间点找到对应的scn号码:(也可以利用时间来闪回,不过scn更准确)

SQL> select name,FIRST_CHANGE#,NEXT_CHANGE# from v$archived_log where to_date('2011-12-18 20:20;25','yyyy-mm-dd hh24:mi;ss') between FIRST_TIME and NEXT_TIME;
 
NAME                                                                                       FIRST_CHANGE# NEXT_CHANGE#
------------------------------------------------------------------------------------------ ------------- ------------
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_18/o1_mf_1_89_7gvpqmqb_.arc           787226       787539


下面闪回:
SQL> select count(*) from t1 as of scn 787226;
 
  COUNT(*)
----------
      9999
 
SQL> select count(*) from t1 as of scn 787539;
 
  COUNT(*)
----------
      9900

你可能感兴趣的:(oracle)