Oracle Data block 的物理結構

發表于:2012-03-02來源:Csdn作者:xuyubotest點擊數: 標簽:oracle
對data block物理結構的認識 1.Data Block 物理結構圖: 2.一次對block的dump過程:

  對data block物理結構的認識

  1.Data Block 物理結構圖:

  2.一次對block的dump過程:

  PHP code:

SQL> create table t9 (a varchar(10));

Table created.

SQL> insert into t9 values('a');

1 row created.

SQL> commit;

Commit complete.

SQL> set serveroutput on
SQL> exec show_space('T9');
Free Blocks.............................1
Total Blocks............................8
Total Bytes.............................65536
Unused Blocks...........................6
Unused Bytes............................49152
Last Used Ext FileId....................3
Last Used Ext BlockId...................121
Last Used Block.........................2

PL/SQL procedure successfully completed.

SQL> alter system dump datafile 3 block 122;

System altered.

SQL> select * from v$tablespace;

       TS# NAME                           INC
---------- ------------------------------ ---
         0 SYSTEM                         YES
         1 UNDOTBS1                       YES
         8 USERS                          YES
        18 TEMP1

  Trace 文件:

  *** 2004-07-25 15:48:01.000Start dump data blocks tsn: 8 file#: 3 minblk 122 maxblk 122buffer tsn: 8 rdba: 0x00c0007a (3/122)scn: 0x0000.0068d716 seq: 0x01 flg: 0x02 tail: 0xd7160601frmt: 0x02 chkval: 0x0000 type: 0x06=trans dataBlock header dump: 0x00c0007aObject id on Block? Yseg/obj: 0x806d csc: 0x00.68d714 itc: 2 flg: O typ: 1 - DATAfsl: 0 fnx: 0x0 ver: 0x01Itl Xid Uba Flag Lck Scn/Fsc0x01 0x0004.00b.00000fac 0x00801885.008c.56 --U- 1 fsc 0x0000.0068d7160x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000data_block_dump,data header at 0x552105c===============tsiz: 0x1fa0hsiz: 0x14pbl: 0x0552105cbdba: 0x00c0007a76543210flag=--------ntab=1nrow=1frre=-1fsbo=0x14fseo=0x1f9bavsp=0x1f83tosp=0x1f830xe:pti[0] nrow=1 offs=00x12:pri[0] offs=0x1f9bblock_row_dump:tab 0, row 0, @0x1f9btl: 5 fb: --H-FL-- lb: 0x1 cc: 1col 0: [ 1] 61end_of_block_dumpEnd dump data blocks tsn: 8 file#: 3 minblk 122 maxblk 122

  3.先介紹數據塊中包括的3種頭信息:

  首先,數據塊是通過data block buffer cache完成讀和寫操作的,所以它提供了20bytes的Cache Header和4bytes的 Tail給Cache,用來讀取和管理 。

  第2部分是為Transaction層提供的Header信息。它一共占據了48bytes,包括24bytes的控制信息,和一系列的Interested Transaction Slot (ITS)。

  剩下的部分都叫Data Area,用來存儲用戶數據。Data Area也包括data header,和row data及剩余空間。但是Cluster blocks, table blocks, index block的data header,row data結構是不相同的,這里主要介紹table blocks.

  4. 結合trace文件中的信息,詳細介紹:

  1) The Cache Header and Tail:

  buffer tsn: 8 rdba: 0x00c0007a (3/122)

  scn: 0x0000.0068d716 seq: 0x01 flg: 0x02 tail: 0xd7160601

  frmt: 0x02 chkval: 0x0000 type: 0x06=trans data

  Database block address: 占用4 bytes,表示Tablespace relative database block address(RDBA)。包括tns=8,即Tablespace number (User 表空間),file#=3, block_id=122

  SCN: 占用6bytes,表示最后變化的scn.包括2bytes的高位字節(SCN wrap),和4bytes的低位字節(SCN base)

  Sequence: 占用1byte,用途不明確,可能是輔助SCN的變化

  Flag: 占用1byte

  Format: 占用1byte,應該是用來區分版本。Oracle 8之前值為1,之后為2.

  Checksum: 占用2byte,跟db_block_checksum 參數有關系。

  引用oracle document 的解釋:“DB_BLOCK_CHECKSUM determines whether DBWn and the direct loader will calculate a checksum (a number calculated from all the bytes stored in the block) and store it in the cache header of every data block when writing it to disk. Checksums are verified when a block is read-only if this parameter is true and the last write of the block stored a checksum. In addition, Oracle gives every log block a checksum before writing it to the current log.

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97