手机版
你好,游客 登录 注册
背景:
阅读新闻

Oracle Undo 原理

[日期:2013-03-04] 来源:Linux社区  作者:jlhnxly [字体:大 中 小]

c2 19 33为2450,是第二条更新的数据
update emp set sal = 4000 where empno = 7782;


*-----------------------------
* Rec #0x30  slt: 0x08  objn: 73181(0x00011ddd)  objd: 73181  tblspc: 4(0x00000004)
*      Layer:  11 (Row)  opc: 1  rci 0x2f
Undo type:  Regular undo  Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
rdba: 0x00000000
*-----------------------------
KDO undo record:
KTB Redo
op: 0x02  ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C  uba: 0x00c00d13.01ea.2f
KDO Op code: URP row dependencies Disabled
  xtype: XAxtype KDO_KDOM2 flags: 0x00000080  bdba: 0x01000097  hdba: 0x01000092
itli: 2  ispac: 0  maxfr: 4858
tabn: 0 slot: 7(0x7) flag: 0x2c lock: 2 ckix: 77
ncol: 8 nnew: 1 size: 0
Vector content:
col  5: [ 2]  c2 29


4000,更新为原记录相同的值也会被记录
update emp set sal = 4000 where empno = 7788;


*-----------------------------
* Rec #0x2f  slt: 0x08  objn: 73181(0x00011ddd)  objd: 73181  tblspc: 4(0x00000004)
*      Layer:  11 (Row)  opc: 1  rci 0x00
Undo type:  Regular undo    Begin trans    Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
rdba: 0x00000000Ext idx: 0
flg2: 0
*-----------------------------
uba: 0x00c00d13.01ea.2c ctl max scn: 0x0000.001a98dd prv tx scn: 0x0000.001a9906
txn start scn: scn: 0x0000.001a9487 logon user: 84
 prev brb: 12586249 prev bcl: 0
KDO undo record:
KTB Redo
op: 0x04  ver: 0x01
compat bit: 4 (post-11) padding: 1
op: L  itl: xid:  0x0003.01e.0000033c uba: 0x00c000fb.01d7.03
                      flg: C---    lkc:  0    scn: 0x0000.0017ef1e
KDO Op code: URP row dependencies Disabled
  xtype: XAxtype KDO_KDOM2 flags: 0x00000080  bdba: 0x01000097  hdba: 0x01000092
itli: 2  ispac: 0  maxfr: 4858
tabn: 0 slot: 7(0x7) flag: 0x2c lock: 0 ckix: 191
ncol: 8 nnew: 1 size: 0
Vector content:
col  5: [ 2]  c2 1f


3000,正是每一条更新的记录,所以其Undo Chain的指针为0x00,表示这是最后一条记录。
update emp set sal = 4000 where empno = 7788;


也可以从x$bh中找到这些数据块:
SYS@ orcl> select b.segment_name, a.file#, a.dbarfil, a.dbablk, a.class, a.state
  2  from x$bh a, dba_extents b where a.dbarfil = b.relative_fno
  3  and b.owner = 'SCOTT' and b.segment_name = 'EMP'
  4  and a.dbablk >= b.block_id and a.dbablk < b.block_id + b.blocks;
SEGMENT_NAME        FILE#    DBARFIL    DBABLK      CLASS      STATE
--------------- ---------- ---------- ---------- ---------- ----------
EMP                      4          4        151          1          1
EMP                      4          4        151          1          3
EMP                      4          4        146          4          3
EMP                      4          4        146          4          3
EMP                      4          4        146          4          3


class为4的代表的是段头,class为1,块号为151的为数据块,state为3的代表通过一致性读构造出来的

linux
相关资讯       undo  Oracle Undo 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款