天天看點

【Oracle】 rman 删除歸檔日志的指令

    因為資料倉庫上asm的磁盤空間不足,需要删除早期的歸檔日志,檢視資料有以下兩種方式:

<b>delete archivelog until time 'sysdate-N';</b>

<b>delete archivelog all completed before 'sysdate-N';</b>

這兩個指令的差别在哪裡呢?

使用list 指令來檢視一下究竟...

RMAN&gt; <b> list archivelog until time 'sysdate-1';</b>

using target database control file instead of recovery catalog

List of Archived Log Copies for database with db_unique_name YANGDB

=====================================================================

Key     Thrd Seq     S Low Time 

------- ---- ------- - ---------

459     1    463     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_463_762800109.log

460     1    464     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_464_762800109.log

461     1    465     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_465_762800109.log

462     1    466     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_466_762800109.log

463     1    467     A 09-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_467_762800109.log

464     1    468     A 09-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_468_762800109.log

465     1    469     A 10-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_469_762800109.log

466     1    470     A 11-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_470_762800109.log

467     1    471     A 11-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_471_762800109.log

468     1    472     A 12-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_472_762800109.log

469     1    473     A 13-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_473_762800109.log

470     1    474     A 13-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_474_762800109.log

471     1    475     A 14-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_475_762800109.log

472     1   <b> 476 </b>    A 15-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_476_762800109.log

<b>歸檔日志的序列号碼到476</b>

RMAN&gt; list archivelog all completed before 'sysdate-1';

471     1   <b> 475 </b>    A 14-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_475_762800109.log

<b>歸檔日志的序列号碼到475 </b>

<b>檢視v$archived_log 視圖從中擷取 時間和序列号資訊!</b>

SYS@yangdb&gt; select THREAD#,sequence#,FIRST_TIME,COMPLETION_TIME  

2   from v$archived_log order by thread#,sequence#;

THREAD# SEQUENCE# FIRST_TIME      COMPLETION_TIME

------- ---------- -------------- -------------------

1        470  2012-01-11 11:00:10  2012-01-11 22:08:23

1        471  2012-01-11 22:08:20  2012-01-12 17:00:10

1        472  2012-01-12 17:00:10  2012-01-13 02:00:28

1        473  2012-01-13 02:00:28  2012-01-13 22:09:56

1        474  2012-01-13 22:09:55  2012-01-14 22:01:02

<b>1        475  2012-01-14 22:01:02  2012-01-15 06:46:14 ==list archivelog all completed 以COMPLETION_TIME為基準   </b>

<b>1        476  2012-01-15 06:46:14  2012-01-30 14:10:18 ==list archivelog until 以FIRST_TIME 為基準 編号476的日志橫跨15号和30号兩天,以first_time的值來截取!</b>

1        477  2012-01-30 14:10:15  2012-01-30 14:10:23

1        478  2012-01-30 14:10:22  2012-01-30 14:10:29

1        479  2012-01-30 14:10:28  2012-01-30 14:10:33

1        480  2012-01-30 14:10:32  2012-01-30 14:10:40  

總結:

<b>該指令删除日志時的時間基準是first_name</b>

<b>該指令删除日志時的時間基準是completion_time   </b>