Log Switches and Log Sequence Numbers

A log switch is the point at which the database stops writing to one redo log file and begins writing to another. Normally, a log switch occurs when the current redo log file is completely filled and writing must continue to the next redo log file. However, you can configure log switches to occur at regular intervals, regardless of whether the current redo log file is completely filled. You can also force log switches manually.

 

Oracle Database assigns each redo log file a new log sequence number every time a log switch occurs a nd LGWR begins writing to it. When the database archives redo log files, the archived log retains its log sequence number. A redo log file that is cycled back for use is given the next available log sequence number.

--log sequence number 是在如下时刻被分配的: 当  log switch occurs时, the next redo log获得最新的 log sequence number。

举例:

3组日志 :1;2;3 。

2组的状态是current,此时2组的 log sequence number是100

日志切换后:

3组的状态是current,此时3组的 log sequence number是101

 

Each online or archived redo log file is uniquely identified by its log sequence number. During crash, instance, or media recovery, the database properly applies redo log files in ascending order by using the log sequence number of the necessary archived and redo log files.