How to clean up a full Oracle log file?
The primary types of log files in Oracle databases are archived log files and online redo log files. It is important to promptly clear log files once they are full to free up space. The following are the steps for cleaning Oracle log files.
- Clean up and archive log files.
- Connect to the database using SQL*Plus.
- Retrieve the current archived log files and their paths: SELECT * FROM V$ARCHIVED_LOG;
- Delete old archived log files using RMAN or operating system commands. On UNIX/Linux systems, you can use a command like the following to delete expired archived log files: rm -rf /path/to/archive/log
- To verify that the cleanup is complete using SQL*Plus: SELECT COUNT(*) FROM V$ARCHIVED_LOG;
- Clean up and redo online log files.
- Retrieve the current online redo log group and its members: SELECT * FROM V$LOG;
- Switch to the next online redo log group: ALTER SYSTEM SWITCH LOGFILE;
- Remove the old online redo log group that is no longer in use: ALTER DATABASE DROP LOGFILE GROUP n;
- Check the completion of cleaning in SQL*Plus by running: SELECT * FROM V$LOG;
It is important to be cautious when cleaning up Oracle log files to avoid any impact on the normal operation of the database. It is recommended to backup the database before cleaning to prevent any unexpected issues.