标签:com class div code style size string tar ext art color
oracle中undo的信息主要完成下面的功能:
1,块中的事务槽ITL中的UBA表示这个ITL所在的block历经的最后一次改变所对应的undo record所在的UBA,主要用于一致读。
2,undo segment header中的UBA表示所对应的transaction的undo chain的最后一个UBA,用于transaction的回滚。
可以通过v$KTUXE视图来查看undo segment header中的transaction table情况。
下面通过实验来看一下:
1,查看undo segment header。
第一步:更新记录
| 
       1 
      2  | 
    
      SYS/SYS@ORCL>update 
test set name=‘jkkkkkkkkkkkkkkkkkkkkkk‘ 
where id=2;1 row updated. | 
第二步:查看本事务使用的undo segment以及文件和块的情况
| 
       1 
      2 
      3 
      4 
      5 
      6 
      7 
      8 
      9 
      10 
      11 
      12 
      13  | 
    
      SYS/SYS@ORCL>select 
XIDUSN as segment_id, ubafil as 
file_id, ubablk, start_ubablk, used_ublk from 
v$transaction;SEGMENT_ID    FILE_ID     UBABLK START_UBABLK  USED_UBLK---------- ---------- ---------- ------------ ----------        10          2        715          715          11 row selected.SYS/SYS@ORCL>select 
segment_name, segment_id, file_id,block_id from 
dba_rollback_segs where 
segment_id=10;SEGMENT_NAME                                                 SEGMENT_ID    FILE_ID   BLOCK_ID------------------------------------------------------------ ---------- ---------- ----------_SYSSMU10$                                                           10          2        1531 row selected. | 
所以,本事务使用的undo segment_id为10,file_id为2,undo segment header的block_id为153。 下面dump这个undo segment header来看下:
| 
       1 
      2 
      3 
      4 
      5 
      6 
      7 
      8 
      9 
      10 
      11 
      12 
      13 
      14 
      15 
      16 
      17 
      18 
      19 
      20 
      21 
      22 
      23 
      24 
      25 
      26 
      27 
      28 
      29 
      30 
      31 
      32 
      33 
      34 
      35 
      36 
      37 
      38 
      39 
      40 
      41 
      42 
      43 
      44 
      45 
      46 
      47 
      48 
      49 
      50 
      51 
      52 
      53 
      54 
      55 
      56 
      57 
      58 
      59 
      60 
      61 
      62 
      63 
      64 
      65 
      66 
      67 
      68 
      69  | 
    
        Extent Header:: spare1: 0      spare2: 0      #extents: 3      #blocks: 143                     last 
map  0x00000000  #maps: 0      offset: 4080        Highwater::  0x008002cd  ext#: 2      blk#: 68     ext size: 128     #blocks in 
seg. hdr‘s freelists: 0       #blocks below: 0       mapblk  0x00000000  offset: 2                        Unlocked     Map Header:: next  
0x00000000  #extents: 3    obj#: 0      flag: 0x40000000  Extent Map  -----------------------------------------------------------------   0x0080009a  length: 7        0x008000d9  length: 8        0x00800289  length: 128       Retention Table  ----------------------------------------------------------- Extent Number:0  Commit 
Time: 1326479408 Extent Number:1  Commit 
Time: 1326479408 Extent Number:2  Commit 
Time: 1326479408     TRN CTL:: seq: 0x00f4 chd: 0x0021 ctl: 0x002b inc: 0x00000000 nfb: 0x0002            mgc: 0x8201 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)            uba: 0x008002cb.00f4.0c scn: 0x0000.000ddd2fVersion: 0x01  FREE 
BLOCK POOL::    uba: 0x00000000.00f4.0b ext: 0x2  spc: 0x1a64      uba: 0x008002cc.00f4.11 ext: 0x2  spc: 0xf9c       uba: 0x008002cd.00f4.01 ext: 0x2  spc: 0x1f88      uba: 0x00000000.00eb.01 ext: 0x2  spc: 0x1f88      uba: 0x00000000.00eb.01 ext: 0x2  spc: 0x1f88    TRN TBL::    index  
state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num    cmt  ------------------------------------------------------------------------------------------------   0x00    9    0x00  0x00f9  0x0011  0x0000.000e3357  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543   0x01    9    0x00  0x00f9  0x0000  0x0000.000e3297  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654005   0x02    9    0x00  0x00f9  0x0006  0x0000.000e2fe0  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326652743   0x03    9    0x00  0x00f9  0x0008  0x0000.000e3153  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x04    9    0x00  0x00f9  0x002d  0x0000.000e30f3  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x05    9    0x00  0x00f9  0x000c  0x0000.000e312a  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x06    9    0x00  0x00f9  0x0025  0x0000.000e30be  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x07    9    0x00  0x00f9  0x0015  0x0000.000e3188  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x08    9    0x00  0x00f9  0x000d  0x0000.000e315e  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x09    9    0x00  0x00f9  0x002e  0x0000.000e3115  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x0a    9    0x00  0x00f9  0x000e  0x0000.000e3173  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x0b    9    0x00  0x00f9  0x0009  0x0000.000e3108  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x0c    9    0x00  0x00f9  0x0028  0x0000.000e3134  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x0d    9    0x00  0x00f9  0x000a  0x0000.000e3168  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x0e    9    0x00  0x00f9  0x0007  0x0000.000e317e  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343   0x0f    9    0x00  0x00f9  0x0010  0x0000.000e3376  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543   0x10    9    0x00  0x00f9  0x0014  0x0000.000e3381  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543   0x11    9    0x00  0x00f9  0x000f  0x0000.000e3364  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543   0x12    9    0x00  0x00f9  0x001c  0x0000.000e37f2  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326657606   0x13    9    0x00  0x00f8  0x001a  0x0000.000ddd4a  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326492007   0x14    9    0x00  0x00f9  0x0016  0x0000.000e34ee  0x008002bf  0x0000.000.00000000  0x00000001   0x00000000  1326655603   0x15    9    0x00  0x00f9  0x0001  0x0000.000e3286  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654003   0x16    9    0x00  0x00f9  0x001b  0x0000.000e352d  0x008002bf  0x0000.000.00000000  0x00000001   0x00000000  1326655743   0x17    9    0x00  0x00f9  0x0018  0x0000.000e3568  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326655803   0x18    9    0x00  0x00f9  0x0012  0x0000.000e375b  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326657242   0x19    9    0x00  0x00f9  0x0026  0x0000.000e3554  0x008002c8  0x0000.000.00000000  0x00000003   0x00000000  1326655802   0x1a    9    0x00  0x00f8  0x001d  0x0000.000ddeb0  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326493035   0x1b    9    0x00  0x00f9  0x0019  0x0000.000e3553  0x008002c3  0x0000.000.00000000  0x00000003   0x00000000  1326655802   0x1c    9    0x00  0x00f9  0x002b  0x0000.000e874a  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326657871   0x1d    9    0x00  0x00f8  0x002a  0x0000.000e2e6d  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326652128   0x1e    9    0x00  0x00f8  0x0027  0x0000.000ddd32  0x008002bd  0x0000.000.00000000  0x00000003   0x00000000  1326492003   0x1f    9    0x00  0x00f8  0x0017  0x0000.000e3556  0x008002cc  0x0000.000.00000000  0x00000007   0x00000000  1326655802   0x20    9    0x00  0x00f8  0x001e  0x0000.000ddd31  0x008002ba  0x0000.000.00000000  0x00000003   0x00000000  1326492003   0x21    9    0x00  0x00f8  0x0020  0x0000.000ddd30  0x008002b8  0x0000.000.00000000  0x00000003   0x00000000  1326492003   0x22    9    0x00  0x00f8  0x0002  0x0000.000e2f0d  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326652202 | 
0x23 10 0x80 0x00f9 0x0002 0x0000.000e8781 0x008002cb 0x0000.000.00000000 0x00000001 0x00000000 0然后dump 数据块看一下itl的情况
| 
       1 
      2 
      3 
      4  | 
    
         Itl           Xid                  Uba         Flag  Lck        Scn/Fsc0x01   0x0008.029.0000012a  0x0080036a.00f3.05  C---    0  scn 0x0000.000d6ead0x02   0x000a.023.000000f9  0x008002cb.00f4.0c  ----    1  fsc 0x0000.000000000x03   0x0005.00f.00000148  0x0080004c.019f.16  C---    0  scn 0x0000.000d6ea7 | 
下面再dump undo 块的内容看一下:
| 
       1 
      2 
      3 
      4 
      5 
      6 
      7 
      8  | 
    
      UNDO BLK:  xid: 0x000a.023.000000f9  seq: 0xf4  cnt: 0xc   irb: 0xc   icl: 0x0   flg: 0x0000   Rec Offset      Rec Offset      Rec Offset      Rec Offset      Rec Offset---------------------------------------------------------------------------0x01 0x1f70     0x02 0x1f1c     0x03 0x1e74     0x04 0x1e08     0x05 0x1d84     0x06 0x1d24     0x07 0x1cc4     0x08 0x1bd0     0x09 0x1b4c     0x0a 0x1aec     0x0b 0x1a8c | 
0x0c 0x19ec在itl中: xid中0x000a.023.000000f9, XID由三部分内容组成:XIDUSN(回滚段号),XIDSLOT(回滚段槽 号),XIDSQN(序列号) 0x000a代表undo segment id,即十进制为10。023代表undo segment header中的回滚槽,即transaction table中的一行。 000000f9代表序列号。XID对应一个UBA(undo block address),表示该事务回滚信息的开始位置, 这个通过v$transaction可以对应上:
| 
       1 
      2 
      3 
      4 
      5 
      6 
      7 
      8  | 
    
      SYS/SYS@ORCL>select 
xidusn,xidslot,xidsqn,ubafil,ubablk,ubasqn,ubarec from  2     v$transaction;    XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK     UBASQN     UBAREC---------- ---------- ---------- ---------- ---------- ---------- ----------        10         35        249          2        715        244         121 row selected. | 
XIDUSN,XIDSLOT,XIDSQN共同组成了Xid。UBAFIL,UBABLK,UBASQN,UBAREC共同组成了undo segment header中transaction table中的UBA. 在每个data block的ITL中也有一个UBA,实际上这个UBA是指向了该block对应的undo信息的起始位置,这个UBA主要的作用是提供一致性读, 因为一 致性读需要通过undo信息来构造一个CR block,通过这个UBA就可以直接定位到block的回滚信息的起始位置,而不再需要通过undo segment header中的事务表。
oracle core04_undo,码迷,mamicode.com
标签:com class div code style size string tar ext art color
原文地址:http://www.cnblogs.com/xpchild/p/3695136.html