Create a log file in Oracle
The syntax for creating a log file in Oracle is as follows:
Alter database database_name add logfile [group group_number]
(File_name [, file_name [,...]) [SIZE number] [reuse];
The syntax is described as follows;
Group group_number is the ID of the specified group in the log file.
File_name creates a log file Member for this group
Size number indicates the size of log file members.
Reuse if the created Log File member already exists, you can use the reuse keyword to overwrite the existing file. However, if the file cannot belong to another log file group, it cannot be replaced.
Create a log file
Creating a log file generally refers to adding a log member to a log file. You must use the alter database... add logfile member statement.
For example, add a new log file to log file group 4;
Alter database add logfile member
'F: \ orealcfile \ logfile \ record. log' to group 4;
First, query the log file groups in the database:
SQL> select group #, member from v $ logfile;
GROUP # MEMBER
-------------------------------------------------------------------------------
3 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO03.LOG
2 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO02.LOG
1 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO01.LOG
Then, add a log file to the log file group.
SQL> alter database add logfile group 4
(
'F: \ oracledata \ logfile \ redo1.log ',
'F: \ oracledata \ logfile \ redo2.log'
) Size 10 m;
The database has been changed.
Again, we can see that there are 4 more database file groups in the system's Database Log File Group.
SQL> select group #, member from v $ logfile;
GROUP # MEMBER
-------------------------------------------------------------------------------
3 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO03.LOG
2 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO02.LOG
1 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO01.LOG
4 F: \ ORACLEDATA \ LOGFILE \ REDO1.LOG
4 F: \ ORACLEDATA \ LOGFILE \ REDO2.LOG
Create a log file and add it to log group 4.
SQL> alter database add logfile member // add a member to the corresponding log
2 'f: \ oracledata \ logfile \ redo3.log'
3 to group 4;
The database has been changed.
SQL> select group #, member from v $ logfile; // System Database Log File group
GROUP # MEMBER
-------------------------------------------------------------------------------
3 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO03.LOG
2 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO02.LOG
2 D: \ ORACLE \ ORADATA \ ORACLE12C \ REDO01.LOG
4 F: \ ORACLEDATA \ LOGFILE \ REDO1.LOG
4 F: \ ORACLEDATA \ LOGFILE \ REDO2.LOG
3 F: \ ORACLEDATA \ LOGFILE \ REDO3.LOG