Home » Oracle » Oracle Database » How to delete the archive logs in Oracle

How to delete the archive logs in Oracle

Archive logs keep accumulating and we need to put things in place to delete them on a regular basis. We should not be deleting the archivelog from the filesystem directly as the Oracle Database is not aware of that and space is not released in the Flash recovery area

Let’s see a few commands on How to delete the archive logs in Oracle

How to delete the archivelog after the backup is done

BACKUP  ARCHIVELOG delete ALL INPUT;

This will delete the archivelog once the backup is done on the channel-defined

You can use this together with the database also

BACKUP DATABASE PLUS ARCHIVELOG delete ALL INPUT;

How to delete the archive logs which are backed off

delete archivelog UNTIL TIME = 'SYSDATE-1.5' backed up 1 times to sbt_tape;

You can change the timing accordingly. If you are backing up to Disk only, then you can specify the below command

delete archivelog UNTIL TIME = 'SYSDATE-1.5' backed up 1 times to disk;

This command will ask for the Prompt to delete the archivelog, if you want to delete without any prompt, use the below command

delete noprompt archivelog UNTIL TIME = 'SYSDATE-1.5' backed up 1 times to disk;

Suppose you want to delete the archivelog older than 1 hour, you can use the below command

delete archivelog UNTIL TIME = 'SYSDATE-1/24' backed up 1 times to disk;

How to delete the archive logs

We can delete the archive logs whether backed up or not using the below command. The below command will delete archive older than 1 day

delete archivelog UNTIL TIME = 'SYSDATE-1' ;

If you want to delete older than 12 hours, then it will be

delete archivelog UNTIL TIME = 'SYSDATE-2/24' ;

If you want to delete older than 7 days, then it will be

delete archivelog UNTIL TIME = 'SYSDATE-7' ;

This command will ask for the Prompt to delete the archivelog, if you want to delete without any prompt, then please add noprompt

See also  how to check sql profile in oracle

Important Note: This might not work if you have standby and configure archive deletion policy

How to delete the expired archive logs

Suppose you manually deleted the archive log from FRA, then the below steps can be done to remove those from the FRA dictionary

rman target /
list expired archivelog all;
crosscheck archivelog all;
list expired archivelog all;
delete expired archivelog all;

Delete the archive logs from a particular archive dest

Suppose you are using two archive locations to store the archive logs, then you can use the below command to delete it

delete archivelog LIKE '%arc_dest_1%' UNTIL TIME = 'SYSDATE-1/24' ;

How to delete all archivelog

delete archivelog  all

Important Note for archive log deletion

Above all archive deletion will also depend on two more things

  1. If you have set a standby destination,
  2. rman archivelog deletion policy

The above delete script might give some warning depending on the settings of these. The delete need to make sure these condition are met.Oracle keep changing this condition with Oracle versions and we have some bugs on this.

Delete Archivelog Force

If the archivelog command above are giving warning for backup not happen or archive log not applied on standby but if you still want to delete then you can use force in delete

delete force archivelog  all

I hope you like this post on How to delete the archive logs in Oracle.

Related Articles

How to check archive log location in Oracle
RMAN List backup commands: RMAN List backup commands are used to list the backup taken using RMAN, Date and Time and many other details are included
How to recover database using RMAN: How to recover database using RMAN, how to recover from datafile loss, tablespace loss and whole database loss
RMAN crosscheck :check out this post on RMAN crosscheck command, Crosscheck backup, crosscheck archivelog all, Crosscheck backup
RMAN-06059: Check out how to resolve the RMAN-06059: expected archived log not found, lost of archived log compromises recoverability

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top