欢迎光临
我们一直在努力

Oracle怎么查看事务信息

本篇内容介绍了“Oracle怎么查看事务信息”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

数据库版本:
Oracle 11.2.0.3 RAC

实验目的:
通过undo块查看Oracle事务信息

实验细节:
1 开始一个事务
SQL> select * from t1;

        ID NAME
———- ——————————
         1 ycr
         2 zhy
         3 wya
         5 lj
         4 zhb
         2 mk
         2 cc

SQL> update t1 set id=6 where name='cc';

1 row updated.
此事务不要commit或者rollback。

2 查看事务信息
a)查看session号:
SQL> select sid from v$mystat where rownum=1;

       SID
———-
        27

b)获取undo槽位等信息:
SQL> select xidusn,xidslot,xidsqn from V$TRANSACTION t,v$session s where s.sid=27 and s.taddr=t.addr;

    XIDUSN    XIDSLOT     XIDSQN
———- ———- ———-
        10         26       1741

SQL> select sid,trunc(id1/65536) usn,mod(id1,65536) slot,id2 wrap,lmode from v$lock where type='TX' and sid='27';

       SID        USN       SLOT       WRAP      LMODE
———- ———- ———- ———- ———-
        27         10         26       1741          6

其中
Column Description
XIDUSN Undo segment number
XIDSLOT Slot number
XIDSQN Sequence number

3 根据查询到的信息找到undo块:
a)查看undo块头位置
SQL> clear columns
columns cleared
SQL> col name for a40
SQL> select * from v$rollname where usn=10;  

       USN NAME
———- —————————————-
        10 _SYSSMU10_3271578125$

b)dump undo块
alter system dump undo header"_SYSSMU10_3271578125$";
select * from v$diag_info where name='Default Trace File';
/u01/app/oracle/diag/rdbms/irac/IRAC1/trace/IRAC1_ora_4444.trc

c)查看undo块头信息:
 index  state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num    cmt
  ————————————————————————————————
     0x19    9    0x00  0x06d0  0x0012  0x0000.00b6ed00  0x00c00382  0x0000.000.00000000  0x00000001   0x00000000  1509426012
   0x1a   10    0x80  0x06cd  0x0004  0x0000.00b6f712  0x00c00397  0x0000.000.00000000  0x00000001   0x00000000  0
   0x1b    9    0x00  0x06ce  0x0002  0x0000.00b6ed4f  0x00c00397  0x0000.000.00000000  0x00000003   0x00000000  1509426012
可以看到找到了对应的事务
state为10说明为活动事务,warp#为0x06cd同v$lock查到的信息相同,换算成10进制为1741。

“Oracle怎么查看事务信息”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注云搜网网站,小编将为大家输出更多高质量的实用文章!

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。