--事务查看
create table t1 as select object_id,object_name from dba_objects where object_id < 10;
select dbms_rowid.rowid_relative_fno(rowid) fno,dbms_rowid.rowid_block_number(rowid) blk#,dbms_rowid.rowid_row_number(rowid) row#,object_id from t1;
FNO BLK# ROW# OBJECT_ID
---------- ---------- ---------- ----------
7 395 0 2
7 395 1 3
7 395 2 4
7 395 3 5
7 395 4 6
7 395 5 7
7 395 6 8
7 395 7 9
8 rows selected.
delete from t1 where objecT_id=2;
commit;
alter system checkpoint;
++++Session 2
BBED> set dba 7,371
DBA 0x01c00173 (29360499 7,371)
BBED> map /v
File: /oradata/ORCL/users01.dbf (7)
Block: 395 Dba:0x01c0018b
------------------------------------------------------------
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
ub1 type_kcbh @0
ub1 frmt_kcbh @1
ub2 wrp2_kcbh @2
ub4 rdba_kcbh @4
ub4 bas_kcbh @8
ub2 wrp_kcbh @12
ub1 seq_kcbh @14
ub1 flg_kcbh @15
ub2 chkval_kcbh @16
ub2 spare3_kcbh @18
struct ktbbh, 96 bytes @20
ub1 ktbbhtyp @20
union ktbbhsid, 4 bytes @24
struct ktbbhcsc, 8 bytes @28
sb2 ktbbhict @36
ub1 ktbbhflg @38
ub1 ktbbhfsl @39
ub4 ktbbhfnx @40
struct ktbbhitl[3], 72 bytes @44 --事务槽
struct kdbh, 14 bytes @124
ub1 kdbhflag @124
sb1 kdbhntab @125
sb2 kdbhnrow @126
sb2 kdbhfrre @128
sb2 kdbhfsbo @130
sb2 kdbhfseo @132
sb2 kdbhavsp @134
sb2 kdbhtosp @136
struct kdbt[1], 4 bytes @138
sb2 kdbtoffs @138
sb2 kdbtnrow @140
sb2 kdbr[8] @142 --有8条数据
ub1 freespace[7916] @158
ub1 rowdata[114] @8074
ub4 tailchk @8188
--xid(事务id) 由三部分组成: undo回滚段编号 + 事务表槽号 +undo段循环覆盖使用的次数
--uba(回滚段地址):表示该事务在undo块上被应用的最后一条undo的地址,或者是数据块要回滚的起点
--uba :由三部分组成:回滚块地址 + 序列号 + undo条目的记录号
BBED> p ktbbhitl
struct ktbbhitl[0], 24 bytes @44 --事务槽1
..............
struct ktbbhitl[1], 24 bytes @68 --事务槽2
struct ktbitxid, 8 bytes @68 --xid
ub2 kxidusn @68 0x0004 --回滚段编号
ub2 kxidslt @70 0x0018 --事务槽slot编号
ub4 kxidsqn @72 0x00000368 --seq 值
struct ktbituba, 8 bytes @76 --uba
ub4 kubadba @76 0x01000274 --表示该事务所使用的undo block的dba地址
ub2 kubaseq @80 0x00bc --uba seq值
ub1 kubarec @82 0x06 --uba record编号
ub2 ktbitflg @84 0x2001 (KTBFUPB) --重要:20表示状态01表示该事物锁定的行记录数
union _ktbitun, 2 bytes @86
sb2 _ktbitfsc @86 104
ub2 _ktbitwrp @86 0x0068 --fast commit scn的高位
ub4 ktbitbas @88 0x0025dd78 --fast commit scn的低位
struct ktbbhitl[2], 24 bytes @92 --事务槽2
struct ktbitxid, 8 bytes @92
ub2 kxidusn @92 0x0000
ub2 kxidslt @94 0x0000
ub4 kxidsqn @96 0x00000000
struct ktbituba, 8 bytes @100
ub4 kubadba @100 0x00000000
ub2 kubaseq @104 0x0000
ub1 kubarec @106 0x00
ub2 ktbitflg @108 0x0000 (NONE)
union _ktbitun, 2 bytes @110
sb2 _ktbitfsc @110 0
ub2 _ktbitwrp @110 0x0000
ub4 ktbitbas @112 0x00000000
BBED>
-- 模拟手工提交某个事务
create table t2 as select object_id,object_name from dba_objects where object_id < 10;
select dbms_rowid.rowid_relative_fno(rowid) fno,dbms_rowid.rowid_block_number(rowid) blk#,dbms_rowid.rowid_row_number(rowid) row#,object_id from t2;
FNO BLK# ROW# OBJECT_ID
---------- ---------- ---------- ----------
7 403 0 2
7 403 1 3
7 403 2 4
7 403 3 5
7 403 4 6
7 403 5 7
7 403 6 8
7 403 7 9
8 rows selected.
delete from t2 where object_id=2; -- 不提交
alter system checkpoint;
----SESSION 2
BBED> set dba 7,403
DBA 0x01c0017b (29360507 7,379)
BBED> p ktbbhitl
..........................
struct ktbbhitl[1], 24 bytes @68
struct ktbitxid, 8 bytes @68
ub2 kxidusn @68 0x0006
ub2 kxidslt @70 0x001c
ub4 kxidsqn @72 0x00000367
struct ktbituba, 8 bytes @76
ub4 kubadba @76 0x010000da
ub2 kubaseq @80 0x00ce
ub1 kubarec @82 0x2a
ub2 ktbitflg @84 0x0001 (NONE) --已提交是0x8000,这个需要修改成0x8000
union _ktbitun, 2 bytes @86
sb2 _ktbitfsc @86 11 --这里需要修改成0
ub2 _ktbitwrp @86 0x000b
ub4 ktbitbas @88 0x00000000
modify /x 0080 offset 84
sum apply
modify /x 0000 offset 86
sum apply
--session 3:
alter system flush buffer_cache;
select count(1) from t2;---发现数据变成了7条,delete没提交的已被提交
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




