熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

數據塊轉儲及RDBA的轉換

2013-11-13 16:16:32  來源: Oracle 

  很多時候我們在進行進一步研究時需要轉儲(dump)Oracle的數據塊以研究其內容Oracle提供了很好的方式我們通過以下例子簡單說明一下:
  
  [oracle@jumper udump]$ sqlplus / as sysdba
  
  SQL*Plus: Release Production on Tue Aug ::
  
  Copyright (c) Oracle Corporation All rights reserved
  
  Connected to:
  Oraclei Enterprise Edition Release Production
  With the Partitioning OLAP and Oracle Data Mining options
  JServer Release Production
  
  SQL> select rowiddeptnodnameloc from scottdept;
  
  ROWID         DEPTNO DNAME     LOC
  
  AAADZAABAAAGKAAA     ACCOUNTING   NEW YORK
  AAADZAABAAAGKAAB     RESEARCH    DALLAS
  AAADZAABAAAGKAAC     SALES     CHICAGO
  AAADZAABAAAGKAAD     OPERATIONS   BOSTON
  
  SQL> select file_idblock_idblocks from dba_extents where segment_name=DEPT;
  
  FILE_ID  BLOCK_ID   BLOCKS
  
             
  
  SQL> alter system dump datafile block min block max ;
  
  System altered
  
  SQL> !
  [oracle@jumper udump]$ ls l
  total
  rwr  oracle  dba      Aug : hsjf_ora_trc
  [oracle@jumper udump]$ more hsjf_ora_trc
  /opt/oracle/admin/hsjf/udump/hsjf_ora_trc
  Oraclei Enterprise Edition Release Production
  With the Partitioning OLAP and Oracle Data Mining options
  JServer Release Production
  ORACLE_HOME = /opt/oracle/product/
  System name:  Linux
  Node name:   cn
  Release:    
  Version:    # Wed Sep :: EDT
  Machine:    i
  Instance name: hsjf
  Redo thread mounted by this instance:
  Oracle process number:
  Unix process pid: image: oraccn (TNS VV)
  
  *** ::
  *** SESSION ID:() ::
  Start dump data blocks tsn: file#: minblk maxblk
  buffer tsn: rdba: xb (/)
  scn: xcd seq: x flg: x tail: xcd
  frmt: x chkval: xe type: x=DATA SEGMENT HEADER UNLIMITED
   Extent Control Header
   
   Extent Header:: spare:    spare:    #extents:    #blocks:
         last map x #maps:    offset:
   Highwater:: xbb ext#:    blk#:    ext size:
   #blocks in seg hdrs freelists:
   #blocks below:
   mapblk x offset:
          Unlocked
   Map Header:: next x #extents:   obj#:  flag: x
   Extent Map
   
  xba length:
  
   nfl = nfb = typ = nxf = ccnt =
   SEG LST:: flg: USED  lhd: xba ltl: xba
  buffer tsn: rdba: xba (/)
  scn: xb seq: x flg: x tail: xb
  frmt: x chkval: xae type: x=trans data
  Block header dump: xba
   Object id on Block? Y
   seg/obj: xb csc: xa itc:  flg: O typ: DATA
   fsl:  fnx: x ver: x
  
   Itl      Xid         Uba     Flag Lck    Scn/Fsc
  x  xaf xb C   scn xce
  x  x x    fsc x
  
  data_block_dumpdata header at xadbc
  ===============
  tsiz: xfa
  hsiz: xa
  pbl: xadbc
  bdba: xba
  
  flag=
  ntab=
  nrow=
  frre=
  fsbo=xa
  fseo=xf
  avsp=xfa
  tosp=xfa
  xe:pti[]   nrow= offs=
  x:pri[]   offs=xf
  x:pri[]   offs=xf
  x:pri[]   offs=xfc
  x:pri[]   offs=xf
  block_row_dump:
  tab row @xf
  tl: fb: HFL lb: x cc:
  col : [ ] c b
  col : []  f e e
  col : [ ] e f b
  tab row @xf
  tl: fb: HFL lb: x cc:
  col : [ ] c
  col : [ ] 
  col : [ ]  c c
  tab row @xfc
  tl: fb: HFL lb: x cc:
  col : [ ] c f
  col : [ ]  c
  col : [ ]  f
  tab row @xf
  tl: fb: HFL lb: x cc:
  col : [ ] c
  col : [] f f e
  col : [ ]  f f e
  end_of_block_dump
  End dump data blocks tsn: file#: minblk maxblk
  
  很多人經常提出的一個問題是rdba是如何轉換的?
  
  rdba: xba (/)
  
  我們通過這個例子介紹一下
  
  rdba從Oracle>Oracle>Oracle發生了三次改變:
  
  在Oraclerdba由進制數表示也就是說數據塊最多只能有^=個數據文件(去掉全和全 實際上最多只能代表個文件)
  
  在Oraclerdba中的文件號增加為為了向後兼容從Block號的高位拿出位作為文件號的高位這樣從>的Rowid無需發生變化
  
  在Oracle文件號仍然用位表示只是不再需要置換為了向後兼容同時引入了相對文件號(rfile#)所以從Oracle到OracleRowid仍然無需發生變化
  
  舉例說明如下:
  
  在Oracle中:
  比如: file block
   位block號==
   vv vvvvvvvv vvvvvvvv vvvvvvvv
     
  ^^^^^^
  位文件號==
  
  在Oracle中:
  比如:File block
  
     
   F  C  C     D  E    C
  \_____/\___/\_______________________/
  |   |    |
  |   | Block = xDEC =
  \_____________
     |      V  V
      = xFF = 注意這裡高位和低位要置換才能得出正確的file#
  
  在Oracle中:
  比如:File block
  
     
   F  C  C     D  E    C
  \_____/\___/\_______________________/
  |   |    |
  |   | Block = xDEC =
  \_____________
     |      V  V
    = F = 這就是相對文件號
  
  對於我們測試中的例子:
  
  rdba: xba (/)
  
  也就是:
  
  前位為rfile#: =
  
  後位為Block#: =
From:http://tw.wingwit.com/Article/program/Oracle/201311/18068.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.