实验: Oracle事务(ITL)
2011-05-17 22:35
423 查看
1 建表,插入数据
SQL> create table test(id number, name varchar2(10));
Table created
SQL> insert into test values(1, 'a');
1 row inserted
SQL> select id,
2 name,
3 rowid,
4 dbms_rowid.rowid_relative_fno(rowid) file#,
5 dbms_rowid.rowid_block_number(rowid) block#
6 from test;
ID NAME ROWID FILE# BLOCK#
---------- ---------- ------------------ ---------- ----------
1 a AAANLOAAEAAAAMAAAA 4 768
2 Dump块
SQL> alter system dump datafile 4 block 768;
System altered
从udump文件中Trace文件可以得信息:
=======================================================================================
……
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.012.0000020d 0x008000af.01cf.1d ---- 1 fsc 0x0000.00000000
0x02 0x000a.007.000001cd 0x0080035c.0148.0d --U- 1 fsc 0x0007.001a603f
……
=======================================================================================
ITL中的xid:0x0005.020.0000020e是由undo信息组成的:xidusn.xidslot.xidsqn
ITL中的uba:0x0080024d.0129.1f是由uba(undo block address).UBASQN.UBAREC
undo block address是0080024d,是一个16进制数,可以通过如下函数转换为UBAFIL和UBABLK
3 分解xid
SQL> select to_number('0008','xxxxx') xidusn from dual;
XIDUSN
----------
8
SQL> select to_number('012','xxxxx') xidslot from dual;
XIDSLOT
----------
18
SQL> select to_number('0000020d','xxxxxxxxx') xidsqn from dual;
XIDSQN
----------
525
4 分解uba
SQL> select dbms_utility.data_block_address_file(to_number('008000af','xxxxxxxx')) UBAFIL from dual;
UBAFIL
----------
2
SQL> select dbms_utility.data_block_address_block(to_number('008000af','xxxxxxxx')) UBABLK from dual;
UBABLK
----------
175
SQL> select to_number('01cf','xxxxxxxxx') UBASQN from dual;
UBASQN
----------
463
SQL> select to_number('1d','xxxxxxxxx') UBAREC from dual;
UBAREC
----------
29
5 dump信息和v$transaction比较
SQL> select xidusn, xidslot, xidsqn, ubafil, ubablk, ubasqn, ubarec from v$transaction;
XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC
---------- ---------- ---------- ---------- ---------- ---------- ----------
8 18 525 2 175 463 29
6 数据块锁定
在另一个会话中操作:
SQL> insert into test values(2, 'a');
1 row inserted
SQL> select id,
2 dbms_rowid.rowid_relative_fno(rowid) file#,
3 dbms_rowid.rowid_block_number(rowid) block#
4 from test;
ID FILE# BLOCK#
---------- ---------- ----------
2 4 767
第一个会话由于未提交, 而锁定了数据块768, 所以第二个会话新插入的数据在新的块767, 与之前的768不同.
SQL> create table test(id number, name varchar2(10));
Table created
SQL> insert into test values(1, 'a');
1 row inserted
SQL> select id,
2 name,
3 rowid,
4 dbms_rowid.rowid_relative_fno(rowid) file#,
5 dbms_rowid.rowid_block_number(rowid) block#
6 from test;
ID NAME ROWID FILE# BLOCK#
---------- ---------- ------------------ ---------- ----------
1 a AAANLOAAEAAAAMAAAA 4 768
2 Dump块
SQL> alter system dump datafile 4 block 768;
System altered
从udump文件中Trace文件可以得信息:
=======================================================================================
……
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.012.0000020d 0x008000af.01cf.1d ---- 1 fsc 0x0000.00000000
0x02 0x000a.007.000001cd 0x0080035c.0148.0d --U- 1 fsc 0x0007.001a603f
……
=======================================================================================
ITL中的xid:0x0005.020.0000020e是由undo信息组成的:xidusn.xidslot.xidsqn
ITL中的uba:0x0080024d.0129.1f是由uba(undo block address).UBASQN.UBAREC
undo block address是0080024d,是一个16进制数,可以通过如下函数转换为UBAFIL和UBABLK
3 分解xid
SQL> select to_number('0008','xxxxx') xidusn from dual;
XIDUSN
----------
8
SQL> select to_number('012','xxxxx') xidslot from dual;
XIDSLOT
----------
18
SQL> select to_number('0000020d','xxxxxxxxx') xidsqn from dual;
XIDSQN
----------
525
4 分解uba
SQL> select dbms_utility.data_block_address_file(to_number('008000af','xxxxxxxx')) UBAFIL from dual;
UBAFIL
----------
2
SQL> select dbms_utility.data_block_address_block(to_number('008000af','xxxxxxxx')) UBABLK from dual;
UBABLK
----------
175
SQL> select to_number('01cf','xxxxxxxxx') UBASQN from dual;
UBASQN
----------
463
SQL> select to_number('1d','xxxxxxxxx') UBAREC from dual;
UBAREC
----------
29
5 dump信息和v$transaction比较
SQL> select xidusn, xidslot, xidsqn, ubafil, ubablk, ubasqn, ubarec from v$transaction;
XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC
---------- ---------- ---------- ---------- ---------- ---------- ----------
8 18 525 2 175 463 29
6 数据块锁定
在另一个会话中操作:
SQL> insert into test values(2, 'a');
1 row inserted
SQL> select id,
2 dbms_rowid.rowid_relative_fno(rowid) file#,
3 dbms_rowid.rowid_block_number(rowid) block#
4 from test;
ID FILE# BLOCK#
---------- ---------- ----------
2 4 767
第一个会话由于未提交, 而锁定了数据块768, 所以第二个会话新插入的数据在新的块767, 与之前的768不同.
相关文章推荐
- oracle ITL(事务槽)的理解
- 转-oracle ITL(事务槽)的理解
- oracle ITL(事务槽)的理解(转)
- Oracle 事务表实验
- oracle ITL(事务槽)的理解
- 关于Oracle事务的一些实验
- 对oracle ITL(事务槽)的理解
- oracle ITL(事务槽)的理解
- 【ORACLE】事务与一致性:TRN TBL 和ITL基础
- 对oracle ITL(事务槽)的理解
- Oracle12C--Oracle事务处理(十一)
- oracle: OCA-047-题解与实验(7)--REGEXP_REPLACE的用法
- oracle等待事件实验--enq: TX - row lock contention
- Oracle-事务处理开始与结束情况;事务的保存点
- Oracle的选择函数索引实验
- oracle事务知识点小结
- oracle事务处理
- ORACLE如何根据ITL找到前镜像的
- ORACLE空间管理实验8:数据块格式分析--DUMP结合BBED
- ORACLE数据库的事务&Oracle事务知识要点