Oracle manually switches log files and clears log files
Oracle switch log file group
Log File groups are used cyclically. When a group of log files is full, the Oracle system automatically switches to the next group of log files. When necessary, the database administrator can also manually switch to another log file group. To switch the log file group, use the following statement:
Alter system switch logfile;
Clear Log File groups
If the log files in the log file group are damaged, the database will not be able to archive the damaged log files. This will eventually cause the database to stop running. In this case, you can clear the content in the log file group without shutting down the database.
The syntax for clearing a log file group is as follows:
Alter database clear logfile group group_number;
Note:
The log file group to be cleared cannot be in the current state, that is, the log file group currently in use by the database cannot be cleared.
When there are only two Log File groups in the database, the log file group cannot be cleared.
The specific operations are as follows:
SQL> select group #, status from v $ log; // view the status of the log file
GROUP # STATUS
--------------------------
1 ACTIVE -- activity window sill
2 INACTIVE -- INACTIVE
3 INACTIVE
4 CURRENT -- the log file group currently in use by the database
SQL> alter system switch logfile;
The system has been changed.
The following shows that the database file group has been changed.
SQL> select group #, status from v $ log;
GROUP # STATUS
--------------------------
1 INACTIVE
2 CURRENT
3 INACTIVE
4 ACTIVE
Clear the log file group and initialize the file. The file is not deleted and the knowledge content is cleared.
Alter database clear logfile group 4;