Friday, April 6, 2018

Deleting Archive logs in Oracle

The best practice is to run CROSSCHECK to update the status of archive logs in the repository and then run DELETE to remove the desired files.

RMAN> crosscheck archivelog all;

Delete all the archive logs of the database:
RMAN> delete archivelog all;

To retain ‘n’ days of archive logs (here ‘n’ is 15):
RMAN>  delete archivelog until time ‘SYSDATE-15’;

From ‘n’ days of archive logs till date (here ‘n’ is 15):
RMAN>  delete archivelog from time ‘SYSDATE-15’;

With ‘from’ and ‘to’ days:
RMAN>  delete archivelog from time ‘SYSDATE-15’ until time ‘SYSDATE-5’;

From a particular sequence number:
RMAN> delete archivelog from sequence 1000;

Until a particular sequence number:
RMAN> delete archivelog until sequence 1500;

With ‘from’ and ‘to’ sequence number:
RMAN> delete archivelog from sequence 1000 until sequence 1500;

To delete the archive logs using some pattern:
RMAN> delete archivelog like ' /archivelog/2018_01_01/*17*';


NOPROMPT parameter:
All the above RMAN commands would be prompting the list of archive logs that would be deleted through the command and with the confirmation from the user before deleting, like a ‘yes’ or ‘no’ question.

When ‘noprompt’ statement is used along with them, it does not prompt for yes-no question. Instead, it starts deleting the archive logs soon after list them.

RMAN> delete noprompt archivelog until time ‘SYSDATE-15’;

FORCE parameter:

This parameter deletes specified files, whether or not they exist on the media and removes repository records.  It ignores any I/O errors for the deleted objects. It also ignores any CONFIGURE ARCHIVELOG DELETION POLICY settings.

Sometimes, the archive logs may not get deleted due to some reasons like needed for standby recovery, archive logs not backed up, etc.
During these situations, if we are sure that those logs are not needed anymore, then we can use “force” option to delete it from OS level and from the recovery records forcefully.

RMAN> delete force archivelog until time ‘SYSDATE-15’;



No comments:

Post a Comment