ITPub博客

首页 > Linux操作系统 > Linux操作系统 > data block学习

data block学习

原创 Linux操作系统 作者:rman不是man 时间:2011-07-17 23:31:32 0 删除 编辑

SQL> create table test_block(id number,desct varchar2(20));

 

Table created.

 

SQL> drop table test_block purge;

 

Table dropped.

 

SQL> create table test_block(id number,desct varchar2(20)) tablespace users;

 

Table created.

 

 

SQL> select object_name,object_id,object_type from dba_objects where object_name like '%TEST_BLOCK%';

 

OBJECT_NAME   OBJECT_ID OBJECT_TYPE

--------------------------------------------------------------------------------

TEST_BLOCK  52224     TABLE

 

 

SQL> insert into test_block values(1,'leon');

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> select * from test_block;

 

        ID DESCT

---------- --------------------

         1 leon

 

SQL> select dump(1,16),dump('leon',16) from dual;

 

DUMP(1,16)        DUMP('LEON',16)

----------------- -------------------------

Typ=2 Len=2: c1,2 Typ=96 Len=4: 6c,65,6f,6e

 

SQL> select * from test_block;

 

        ID DESCT

---------- --------------------

         1 leon

 

SQL> select rowid from test_block;

 

ROWID

------------------

AAAMwAAAEAAAABUAAA

 

 

 

SQL> SELECT DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) R_FILE_NO,

DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) BLOCK_NO

FROM test_block WHERE ROWNUM = 1;

  2    3

 R_FILE_NO   BLOCK_NO

---------- ----------

         4         84

 

SQL> alter session set tracefile_identifier='leon_dump';

 

Session altered.

 

SQL> alter system dump datafile 4 block 84;

 

System altered.

 

[oracle@test udump]$ cat leon_ora_2746_leon_dump.trc

 

Start dump data blocks tsn: 4 file#: 4 minblk 84 maxblk 84

buffer tsn: 4 rdba: 0x01000054 (4/84)

scn: 0x0000.00091d63 seq: 0x03 flg: 0x06 tail: 0x1d630603

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

Hex dump of block: st=0, typ_found=1                            

 

Dump of memory from 0x0DF54400 to 0x0DF56400

DF54400 0000A206 01000054 00091D63 06030000  [....T...c.......]

DF54410 000065ED 00000001 0000CC00 00091D12  [.e..............]

DF54420 00000000 00320002 01000051 00120006  [......2.Q.......]

DF54430 00000136 008034BC 00050054 00002001  [6....4..T.... ..]

DF54440 00091D63 00000000 00000000 00000000  [c...............]

DF54450 00000000 00000000 00000000 00000000  [................]

DF54460 00000000 00010100 0014FFFF 1F791F8D  [..............y.]

DF54470 00001F79 1F8D0001 00000000 00000000  [y...............]

DF54480 00000000 00000000 00000000 00000000  [................]

        Repeat 502 times

DF563F0 02012C00 0402C102 6E6F656C 1D630603  [.,......leon..c.]

Block header dump:  0x01000054

 Object id on Block? Y

 seg/obj: 0xcc00 对象ID  csc: 0x00.91d12  itc: 2  flg: E  typ: 1 - DATA

     brn: 0  bdba: 0x1000051 ver: 0x01 opc: 0

     inc: 0  exflg: 0

 

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc

0x01   0x0006.012.00000136  0x008034bc.0054.05  --U-    1  fsc 0x0000.00091d63

0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000

 

data_block_dump,data header at 0xdf54464

===============

tsiz: 0x1f98

hsiz: 0x14

pbl: 0x0df54464

bdba: 0x01000054

     76543210

flag=--------

ntab=1  

nrow=1

 

frre=-1 

fsbo=0x14 块中空闲空间开始的偏移量

fseo=0x1f8d 块中空闲空间结束的偏移量

avsp=0x1f79

tosp=0x1f79

 

0xe:pti[0]      nrow=1  offs=0

0x12:pri[0]     offs=0x1f8d

block_row_dump:

tab 0, row 0, @0x1f8d

 

tl: 11 fb: --H-FL--  lb: 0x1  cc: 2 列数

col  0: [ 2]  c1 02

col  1: [ 4]  6c 65 6f 6e

end_of_block_dump

End dump data blocks tsn: 4 file#: 4 minblk 84 maxblk 84

 

 

拿出最经典的一张concepts中的图来看参照一下:

 

Header (Common and Variable)

The header contains general block information, such as the block address and the type of segment (for example, data or index).

Table Directory

This portion of the data block contains information about the table having rows in this block.

Row Directory

This portion of the data block contains information about the actual rows in the block (including addresses for each row piece in the row data area).

After the space has been allocated in the row directory of a data block's overhead, this space is not reclaimed when the row is deleted. Therefore, a block that is currently empty but had up to 50 rows at one time continues to have 100 bytes allocated in the header for the row directory. Oracle reuses this space only when new rows are inserted in the block.

Overhead

The data block header, table directory, and row directory are referred to collectively as overhead. Some block overhead is fixed in size; the total block overhead size is variable. On average, the fixed and variable portions of data block overhead total 84 to 107 bytes.

Row Data

This portion of the data block contains table or index data. Rows can span blocks.

 

 

 

再来比对我的trace文件

Block header 表头  Cache layer   trans layer  table directory  free list  row directory  row

 

Start dump data blocks tsn: 4 file#: 4 minblk 84 maxblk 84

buffer tsn: 4 rdba: 0x01000054 (4/84)

scn: 0x0000.00091d63 seq: 0x03 flg: 0x06 tail: 0x1d630603

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

Hex dump of block: st=0, typ_found=1                            

scn: 0x0000.00091d63       6bytes 表示这个块最后的系统改变号SCN,低位的4bytes叫做SCN 基码,高位2bytes叫做SCNwrap

seq: 0x03               1bytes表示一个数据块在同一个scn下所做的改变数,如果seq被覆盖,则一个新的SCN必须需要被分配。0xff是保留的,说明这个块已经是损坏的

type: 0x06=trans data     1bytes表示数据块类型 02为undo ,06为table或index   0e为undo段的头部,10表示数据段的头部

flg: 0x06   1bytes具体含义不清楚,1为未使用过的块,2为需要做cleanout操作的块 ,3为checksum被设置过的,8为临时数据

 

Dump of memory from 0x0DF54400 to 0x0DF56400

DF54400 0000A206 01000054 00091D63 06030000  [....T...c.......]

DF54410 000065ED 00000001 0000CC00 00091D12  [.e..............]

DF54420 00000000 00320002 01000051 00120006  [......2.Q.......]

DF54430 00000136 008034BC 00050054 00002001  [6....4..T.... ..]

DF54440 00091D63 00000000 00000000 00000000  [c...............]

DF54450 00000000 00000000 00000000 00000000  [................]

DF54460 00000000 00010100 0014FFFF 1F791F8D  [..............y.]

DF54470 00001F79 1F8D0001 00000000 00000000  [y...............]

DF54480 00000000 00000000 00000000 00000000  [................]

        Repeat 502 times

DF563F0 02012C00 0402C102 6E6F656C 1D630603  [.,......leon..c.]

Block header dump:  0x01000054

 Object id on Block? Y

 seg/obj: 0xcc00 对象ID  csc: 0x00.91d12  itc: 2  flg: E  typ: 1 - DATA

     brn: 0  bdba: 0x1000051 ver: 0x01 opc: 0

     inc: 0  exflg: 0

seg/obj:0xcc00 表示对象的ID号

itc:2 已经被分配的itl的数量

 

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc

0x01   0x0006.012.00000136  0x008034bc.0054.05  --U-    1  fsc 0x0000.00091d63

0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000

 

Itl:intersting transction list

Xid:undo头的事务ID号  0x0006表示undo段,012表示事务00000136事务槽

Uba:undo数据块地址

Flag:C— = 事务已经被提交并且锁也被释放
-B– =
包含ITL入口的undo记录

—T = 在进行块头的SCN清除的时候还在进行事务中

    若为----表示这个行记录所在的事务还未提交或回滚

Lck:在当前块中有一条行记录被锁

 

 

 

data_block_dump,data header at 0xdf54464

===============

tsiz: 0x1f98

hsiz: 0x14

pbl: 0x0df54464

bdba: 0x01000054

     76543210

flag=--------

ntab=1  

nrow=1

 

tsiz: 0x1f98:总共有8088bytes

hsiz: 0x14   头部的大小14bytes

pbl: 0x0df54464  指向buffer的指针

bdba: 0x01000054  数据块地址

ntab=1  segment的编号,如果分区表的一个分区则可能会是其他数字

nrow=1  在这个block中有多少条记录

 

 

frre=-1 

fsbo=0x14

fseo=0x1f8d

avsp=0x1f79

tosp=0x1f79

 

frre=-1 

fsbo=0x14 块中空闲空间开始的偏移量

fseo=0x1f8d 块中空闲空间结束的偏移量

avsp=0x1f79 可用空间

tosp=0x1f79

 

0xe:pti[0]      nrow=1  offs=0

0x12:pri[0]     offs=0x1f8d

block_row_dump:

tab 0, row 0, @0x1f8d

 

 

0xe:pti[0]      nrow=1  offs=0

0x12:pri[0]     offs=0x1f8d第一条记录的位置信息

block_row_dump:

tab 0, row 0, @0x1f8d row中的0表示1条记录,而后面的表示偏移量

 

 

tl: 11 fb: --H-FL--  lb: 0x1  cc: 2

col  0: [ 2]  c1 02

col  1: [ 4]  6c 65 6f 6e

end_of_block_dump

 

 

tl: 11 记录数的总bytes+row header

fb: --H-FL--  flag byte

      C:是否为分区表的成员

      H:是否为行的头所在的片

      F:是否为行的第一片

      L:是否为行的最后一片

      D:是否为删除行

lb: 0x1 

cc: 2 列数

col  0: [ 2]  c1 02

col  1: [ 4]  6c 65 6f 6e

end_of_block_dump

 

End dump data blocks tsn: 4 file#: 4 minblk 84 maxblk 84

datablock_concepts.jpg

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24212278/viewspace-702427/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: asm
请登录后发表评论 登录
全部评论

注册时间:2010-07-08

  • 博文量
    12
  • 访问量
    53096