重做日志文件中的SCN
日志文件头中包含LOW SCN和NEXT SCN
LOW SCN和NEXT SCN表示改日志文件中包含在LOW SCN和NEXT SCN之间的重做信息。对于当前重做日志来说,NEXT SCN为无穷大,即ffffffff,因��最终的SCN是个未知数。
下面就看一下日志文件中的SCN:
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
1 1 141 52428800 1 YES INACTIVE
6043116 13-7月-11
2 1 142 52428800 1 NO CURRENT
604313213-7月-11
3 1 139 52428800 1 YES INACTIVE
6022046 12-7月-11
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
4 1 140 52428800 1 YES INACTIVE
6042663 13-7月-11
SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
6057820
由上可以看出当前日志组2的LOW SCN为6043132,先DUMP当前日志文件,然后在查看TRC如下:
SQL> select member from v$logfile where group# = 2;
MEMBER
--------------------------------------------------------------------------------
D:\ORACLE\PRODUCT\10.2.0\ORADATA\WEIBIN\REDO02.LOG
SQL> alter system dump logfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\WEIBIN\REDO02.LOG';
系统已更改。
查看TRC:
DUMP OF REDO FROM FILE 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\WEIBIN\REDO02.LOG'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
FILE HEADER:
Compatibility Vsn = 169870080=0xa200300
Db ID=4184897545=0xf9707809, Db Name='WEIBIN'
Activation ID=4203641025=0xfa8e78c1
Control Seq=7208=0x1c28, File size=102400=0x19000
File Number=2, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000142, SCN 0x0000005c35fc-0xffffffffffff"
thread: 1 nab: 0xffffffff seq: 0x0000008e hws: 0x1 eot: 1 dis: 0
resetlogs count: 0x2cad510c scn: 0x0000.001489a6 (1345958)
resetlogs terminal rcv count: 0x0 scn: 0x0000.00000000
prev resetlogs count: 0x2b8f370b scn: 0x0000.00089c75 (564341)
prev resetlogs terminal rcv count: 0x0 scn: 0x0000.00000000
Low scn: 0x0000.005c35fc (6043132) 07/13/2011 08:39:53
Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
Enabled scn: 0x0000.001489a6 (1345958) 04/27/2011 09:59:40
SQL> alter system switch logfile;
系统已更改。
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
1 1 141 52428800 1 YES INACTIVE
6043116 13-7月-11
2 1 142 52428800 1 YES ACTIVE
604313213-7月-11
3 1 143 52428800 1 NO CURRENT
605889313-7月-11
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIME
------------- --------------
4 1 140 52428800 1 YES INACTIVE
6042663 13-7月-11
SQL> alter system dump logfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\WEIBIN\REDO02.LOG';
系统已更改。
查看TRC:
DUMP OF REDO FROM FILE 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\WEIBIN\REDO02.LOG'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
FILE HEADER:
Compatibility Vsn = 169870080=0xa200300
Db ID=4184897545=0xf9707809, Db Name='WEIBIN'
Activation ID=4203641025=0xfa8e78c1
Control Seq=7293=0x1c7d, File size=102400=0x19000
File Number=2, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000142, SCN 0x0000005c35fc-0x0000005c738d"
thread: 1 nab: 0x639b seq: 0x0000008e hws: 0x2 eot: 0 dis: 0
resetlogs count: 0x2cad510c scn: 0x0000.001489a6 (1345958)
resetlogs terminal rcv count: 0x0 scn: 0x0000.00000000
prev resetlogs count: 0x2b8f370b scn: 0x0000.00089c75 (564341)
prev resetlogs terminal rcv count: 0x0 scn: 0x0000.00000000
Low scn: 0x0000.005c35fc (6043132) 07/13/2011 08:39:53
Next scn: 0x0000.005c738d (6058893) 07/13/2011 15:19:39
从以上红色部分我们可以注意到LOG FILE2的LOW SCN为6043132,NEXT SCN为6058893,我们可以知道LOGFILE2包含SCN介于6043132和6058893之间的重做信息。我们之前查出的当前SCN(6057820)也包括在LOGFILE2中。