因为数据仓库上asm的磁盘空间不足,需要删除早期的归档日志,查看资料有以下两种方式:
delete archivelog until time 'sysdate-N';
delete archivelog all completed before 'sysdate-N';
这两个命令的差别在哪里呢?
使用list 命令来查看一下究竟...
RMAN> list archivelog until time 'sysdate-1';
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 476 A 15-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_476_762800109.log
归档日志的序列号码到476
RMAN> list archivelog all completed before 'sysdate-1';
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
归档日志的序列号码到475
查看v$archived_log 视图从中获取 时间和序列号信息!
SYS@yangdb> 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
1 475 2012-01-14 22:01:02 2012-01-15 06:46:14 ==list archivelog all completed 以COMPLETION_TIME为基准
1 476 2012-01-15 06:46:14 2012-01-30 14:10:18 ==list archivelog until 以FIRST_TIME 为基准 编号476的日志横跨15号和30号两天,以first_time的值来截取!
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
总结:
delete archivelog until time 'sysdate-N';
该命令删除日志时的时间基准是first_name
delete archivelog all completed before 'sysdate-N';
该命令删除日志时的时间基准是completion_time