Oracle的redo到底記錄了什麼

lawzjf發表於2006-05-11

注意:這裡我們要刪除dept表上的主鍵約束,否則,因為有索引,生成的重做會更多,更復雜。

21:36:24 SQL> conn law/law
已連線。
21:37:33 SQL> alter system switch logfile;

系統已更改。

21:38:04 SQL> select group#,status from v$log;

GROUP# STATUS
---------- -----------
1 CURRENT
2 ACTIVE
3 INACTIVE


21:38:10 SQL> insert into dept values(7,'E','E');

已建立 1 行。

21:38:31 SQL> alter system switch logfile;

系統已更改。

21:38:43 SQL> alter system dump logfile 'E:ORACLEPRODUCT10.2.0ORADATALAWREDO01.LOG';

系統已更改。

21:38:50 SQL> select object_id from dba_objects
21:39:13 2 where object_name='DEPT'
21:39:21 3 /

OBJECT_ID
----------
13245

在匯出檔案中查詢“13245”,可以發現如下資訊:

REDO RECORD - Thread:1 RBA: 0x00009f.0000000a.0010 LEN: 0x01d8 VLD: 0x0d
SCN: 0x0000.002c2494 SUBSCN: 1 05/31/2006 21:38:43
CHANGE #1 TYP:2 CLS: 1 AFN:4 DBA:0x0100004d OBJ:13245 SCN:0x0000.002c2345 SEQ: 1 OP:11.2
KTB Redo
op: 0x11 ver: 0x01
op: F xid: 0x0005.000.000004e7 uba: 0x008016bf.0062.30
Block cleanout record, scn: 0x0000.002c248b ver: 0x01 opt: 0x02, entries follow...
itli: 1 flg: 2 scn: 0x0000.002c1b8d
itli: 2 flg: 2 scn: 0x0000.002c2345
KDO Op code: IRP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0100004d hdba: 0x0100004b
itli: 1 ispac: 0 maxfr: 4858
tabn: 0 slot: 3(0x3) size/delt: 10
fb: --H-FL-- lb: 0x1 cc: 3
null: ---
col 0: [ 2] c1 08 這是我們新增的記錄

col 1: [ 1] 45
col 2: [ 1] 45

CHANGE #2 TYP:0 CLS:25 AFN:2 DBA:0x00800049 OBJ:4294967295 SCN:0x0000.002c244c SEQ: 1 OP:5.2
ktudh redo: slt: 0x0000 sqn: 0x000004e7 flg: 0x0012 siz: 128 fbi: 0
uba: 0x008016bf.0062.30 pxid: 0x0000.000.00000000
CHANGE #3 TYP:0 CLS:26 AFN:2 DBA:0x008016bf OBJ:4294967295 SCN:0x0000.002c244b SEQ: 3 OP:5.1
ktudb redo: siz: 128 spc: 1844 flg: 0x0012 seq: 0x0062 rec: 0x30
xid: 0x0005.000.000004e7
ktubl redo: slt: 0 rci: 0 opc: 11.1 objn: 13245 objd: 13245 tsn: 4
Undo type: Regular undo Begin trans Last buffer split: No
Temp Object: No
Tablespace Undo: No
0x00000000 prev ctl uba: 0x008016bf.0062.2d
prev ctl max cmt scn: 0x0000.002c1f50 prev tx cmt scn: 0x0000.002c1f51
txn start scn: 0x0000.002c2493 logon user: 44 prev brb: 8394426 prev bcl: 0 KDO undo record:
KTB Redo
op: 0x04 ver: 0x01
op: L itl: xid: 0x0006.020.000004e1 uba: 0x00801382.00f5.37
flg: C--- lkc: 0 scn: 0x0000.002c1b8d
KDO Op code: DRP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0100004d hdba: 0x0100004b
itli: 1 ispac: 0 maxfr: 4858
tabn: 0 slot: 3(0x3)

RBA:Relative Byte Address ,日誌序號,塊號,位元組序號

TYP:change type

CLS:block class

AFN:absolute file number

DBA:data block address

如果change不是針對一個具體的資料塊,AFN及DBA都可以為0
結論:insert語句生成了一條redo record,由3個change vector構成。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/37724/viewspace-152538/,如需轉載,請註明出處,否則將追究法律責任。

相關文章