日期:2014-05-16  浏览次数:20445 次

oracle执行DML(事物过程)的深入研究(二)

接上一节的 oracle执行DML(事物过程)的深入研究(一)

如果要了解事务的等待现象,就需要了解事务发生时,在什么阶段、 对哪些数据、 变更为什么形式。 尤其需要了解数据块和撤销区域中的数据修改。若利用 Oracle 提供的转储功能,就能从物理角度上观察被事务所修改的数据信息。接下来通过一个简单的例子进行讨论。

我们实验如下:

?1.修改数据如下:


SQL> update test set owner='HELLO' WHERE ROWNUM=1;??
?
已更新 1 行。??
?
SQL> SELECT rowid,dbms_rowid.rowid_relative_fno(rowid) as fno,dbms_rowid.rowid_block_number(rowid) a??
s blkno from? test where rownum=1;??
?
ROWID???????????????????? FNO????? BLKNO??
------------------ ---------- ----------??
AAAMuBAAEAAAHMRAAp????????? 4????? 29457?

?

可以看到修改该的行数据在第4号文件第29457块上,我们dump其文件内容

SQL> alter system dump datafile 4 block 29457;

系统已更改。

Start dump data blocks tsn: 4 file#: 4 minblk 29457 maxblk 29457
buffer tsn: 4 rdba: 0x01007311 (4/29457)
scn: 0x0000.0045b9bb seq: 0x01 flg: 0x00 tail: 0xb9bb0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x07AB2200 to 0x07AB4200
...
Block header dump:? 0x01007311
?Object id on Block? Y
?seg/obj: 0xcb81? csc: 0x00.1223d9? itc: 3? flg: E? typ: 1 - DATA
???? brn: 0? bdba: 0x1007309 ver: 0x01 opc: 0
???? inc: 0? exflg: 0
?
?Itl?????????? Xid????????????????? Uba???????? Flag? Lck??????? Scn/Fsc
0x01?? 0x000a.026.0000023a? 0x00000000.0000.00? ----??? 0? fsc 0x0000.00000000
0x02?? 0x0001.00d.00000396? 0x0080072c.0119.07? --U-?? 41? fsc 0x1027.001226bd
0x03?? 0x0006.00b.00000bc6? 0x0080005a.04c8.17? ----??? 1? fsc 0x0001.00000000
?data_block_dump,data header at 0x7ab227c
===============
tsiz: 0x1f80
hsiz: 0x9e
pbl: 0x07ab227c
bdba: 0x01007311
???? 76543210
flag=--------
ntab=1
nrow=70
frre=-1
fsbo=0x9e
fseo=0x37f
avsp=0x341
tosp=0x13bb
0xe:pti[0]?nrow=70?offs=0
...
tab 0, row 41, @0x37f
tl: 96 fb: --H-FL-- lb: 0x3? cc: 13
col? 0: [ 5]? 48 45 4c 4c 4f
col? 1: [23]
?2f 33 64 37 30 62 62 33 36 5f 50 6f 6c 69 63 79 43 68 65 63 6b 65 72
col? 2: *NULL*
col? 3: [ 4]? c3 02 04 54
col? 4: *NULL*
col? 5: [ 7]? 53 59 4e 4f 4e 59 4d
col? 6: [ 7]? 78 69 08 1e 0f 11 05
col? 7: [ 7]? 78 69 08 1e 0f 11 05
col? 8: [19]? 32 30 30 35 2d 30 38 2d 33 30 3a 31 34 3a 31 36 3a 30 34
col? 9: [ 5]? 56 41 4c 49 44
col 10: [ 1]? 4e
col 11: [ 1]? 4e
col 12: [ 1]? 4e
tab 0, row 42, @0xe44
tl: 98 fb: --H-FL-- lb: 0x0? cc: 13
col? 0: [ 3]? 53 59 53
col? 1: [24]
?2f 37 36 38 65 65 38 61 30 5f 50 6f 6c 69 63 79 4e 6f 64 65 49 6d 70 6c
col? 2: *NULL*
col? 3: [ 4]? c3 02 04 55
col? 4: *NULL*
col? 5: [10]? 4a 41 56 41 20 43 4c 41 53 53
col? 6: [ 7]? 78 69 08 1e 0f 11 05
col? 7: [ 7]? 78 69 08 1e 0f 11 05
col? 8: [19]? 32 30 30 35 2d 30 38 2d 33 30 3a 31 34 3a 31 36 3a 30 34
col? 9: [ 5]? 56 41 4c 49 44
col 10: [ 1]? 4e
col 11: [ 1]? 4e
col 12: [ 1]? 4e
...
end_of_block_dump
End dump data blocks tsn: 4 file#: 4 minblk 29457 maxblk 29457

通过块转储文件的内容,可确认如下事实: