zoukankan      html  css  js  c++  java
  • Oracle 通过undo块查看事务信息(转)

     

     
    数据库版本:
    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。
     
  • 相关阅读:
    快速读取数字
    std:ios:sync_with_stdio (false)以及局限性
    差分,差分数组
    归并排序
    2020-07-06日报博客
    OAuth2-授权码模式 登录流程
    OAuth2 简介
    SpringSecurity连接数据库
    SpringSecurity中的授权
    SpringSecurity 入门
  • 原文地址:https://www.cnblogs.com/youngerger/p/8685322.html
Copyright © 2011-2022 走看看