语句:
delete archivelog all completed before 'sysdate-7';
delete archivelog until time 'sysdate-7' ;
今天在一个数据库上,删除归档的时候,发现使用命令delete archivelog all completed before 'sysdate-7';并不能删除掉7天前的归档。比如1月份的归档还是存在的。
使用catalog start with,将归档重新注册后,还是删除不掉 。
但是,使用delete archivelog until time 'sysdate-7' ;命令,就可以删除掉。
查询了这两个语句的区别。带complete的语句,主要是删除已备份过的归档,没有备份备份的归档,不会被删除。而第二个语句, 则会删除掉归档,无论备份与否。
参考文档:
https://docs.oracle.com/database/121/RCMRF/rcmsubcl002.htm#RCMRF106
https://docs.oracle.com/database/121/RCMRF/rcmsubcl003.htm#RCMRF112
Complete Steps To Delete Archivelogs Using The Rman Utility (Doc ID 794383.1)
-- 第一篇文档:
archivelogRecordSpecifier
Purpose
Use the archivelogRecordSpecifier subclause to specify a set of archived redo log files for use in RMAN operations.
Syntax
archivelogRecordSpecifier::=
Description of the illustration GUID-EB77C428-351C-4C86-94DB-045EA7FAEAEF-print.eps
archlogRange::=
Description of the illustration GUID-C5D12267-E268-488C-97D7-EB2173DF83AB-print.eps
RMAN queries the V$ARCHIVED_LOG
or RC_ARCHIVED_LOG
view to determine which logs to include in the range. When you specify a time, SCN, or restore point, RMAN determines the range according to the contents of the archived redo log files, not when the logs were created or backed up. When you specify the range by log sequence number, then RMAN uses the sequence number to determine the range.
-- 第二篇文档
completedTimeSpec
Purpose
Use the completedTimeSpec
subclause to specify when a backup or copy completed.
Usage Notes
All date strings must be either:
-
Formatted according to the Global Technology date format specification currently in effect.
-
Created by a SQL expression that returns a
DATE
value, as in the following examples:-
'
SYSDATE-30
' -
TO_DATE('09/30/2013 08:00:00','MM/DD/YYYY HH24:MI:SS')
The
TO_DATE
function specifies dates independently of the current Global Technology environment variable settings. -
Syntax
completedTimeSpec::=
Description of the illustration GUID-55694344-D45C-4A1E-A833-7DC6FF0D1E37-print.eps
Semantics
Syntax Element | Description |
---|---|
| Specifies the time after which the backup was completed (see Example 4-7). |
| Specifies the time before which the backup was completed (see Example 4-9). |
BETWEEN ' date_string ' AND ' date_string ' | Specifies a time range during which the backup was completed (see Example 4-8).
|
-- 第三篇文档,MOS上的文档
其中MOS上有一段是这样说的,“DO NOT DELETE ANY ARCHIVELOGS unless you are certain they have already been backed up.” 从另一方面,也说明了Oracle在删除归档的时候,建议是先备份文档。所以这个MOS中,oracle删除归档,默认已经做了备份了。所以使用的是带有complete语句进行删除的。
If you have a flash recovery area (FRA) configured for your archivelogs, then you will need to use RMAN to clear these archivelogs regularly otherwise you will run out of space in the FRA. Only RMAN will maintain the space management metrics for the FRA.
This note deals with the following question:
How do you delete archivelogs using RMAN which are still within the retention period.
DO NOT DELETE ANY ARCHIVELOGS unless you are certain they have already been backed up.
END