日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Oracle 摘去数据块的面纱

發(fā)布時間:2025/3/15 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oracle 摘去数据块的面纱 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

?

00018000h

6

A2

0

0

0c

0

80

3

8b

61

15

0

0

0

3

4

?

type

frmt

spare1/2

rdba

bas

wrp

seq

flg

?

The Cache Header The Cache Header

?

注:@符號后數(shù)字表示塊內(nèi)偏移字節(jié)數(shù)???????????????

Struct? kcbh? 20 bytes @0?? :此結(jié)構(gòu)體共20字節(jié),塊內(nèi)偏移為0字節(jié),即塊首。

???? ub1 type_kcbh??????? @0?? :1=undo segment header block; 2=undo data block; 5= data segment header block; 6=data block

???? ub1 frmt_kcbh??????? @1?? :應(yīng)該是用來區(qū)分版本。Oracle 8之前值為1,之后為2,我的10g為A2

???? ub1 spare1_kcbh?? @2?? :未被使用

???? ub1 spare2_kcbh?? @3?? :未被使用

???? ub4 rdba_kcbh?????? @4?? :0x0380000c 轉(zhuǎn)換成2進制后它的前10 bit 表示file id(算法不確定);后22 bit 表示的block id

???? ub4 bas_kcbh??? @8?? :低位字節(jié)(SCN base)ub2 wrp_kcbh??? @12? :高位字節(jié)(SCN wrap)

???? ub1 seq_kcbh???????? @14? :參照http://www.itpub.net/thread-100750-4-1.html

???? ub1 flg_kcbh?????????? @15

???? ub2 chkval_kcbh??? @16? :跟db_block_checksum 參數(shù)有關(guān)系。

???? ub2 spare3_kcbh?? @18

?

00018010h

9d

af

0

0

1

0

0

0

4

D0

0

0

6a

51

15

0

?

chkval

Spare3

typ

?

sid

csc

?

The Transaction Header

??????????????????

Struct ?ktbbh? 72 bytes?? ??@20?? :共72 bytes,塊內(nèi)偏移量20 bytes

??? ub1 ktbbhtyp???? @20?? :1byte。1=data; 2=index。后面3字節(jié)空置??????????

??? union ktbbhsid?? @24? :指在OBJ$中記錄的segment的object number??

??? struct ktbbhcsc?? @28? : 前6字節(jié)為SCN at last block cleanout,后2字節(jié)用途不清??

??? b2 ktbbhict????? @36? : ITL 的slot數(shù)量??

??? ub1 ktbbhflg???? @38?????

??? ub1 ktbbhfsl???? @39?????

??? ub4 ktbbhfnx??? @40?? :自由列表中下一塊的地址??

struct ktbbhitl[2] @44? : 2個ITL? 共48字節(jié),塊內(nèi)偏移44字?

?

00018020h

0

0

0

0

2

0

32

0

9

0

80

3

3

0

5

0

?

csc

ktbbhict

flg

fsl

fnx

xid

?

第1個ITL

???? ?xid :? 8bytes。Transaction ID (UndoSeg.Slot.Wrap)(select XIDUSN, XIDSLOT,XIDSQN from v$transaction;)

???? uba :? 8bytes。Undo address (UndoDBA.SeqNo.RecordNo)

? Lck Flag :? 2bytes。

??Scn/Fsc :? 6bytes。Commit SCN或者快速提交(Fast Commit Fsc)的SCN

?

00018030h

74

2

0

0

43

3

80

0

A2

1

29

0

0

80

0

0

?

xid

uba

Lck Flag

Scn/Fsc

00018040h

AE

10

15

0

2

0

0C

0

51

2

0

0

48

0A

80

0

?

Scn/Fsc

第2個ITL

00018050h

D7

1

9

0

0

80

0

0

3D

14

15

0

0

0

0

0

?

第2個ITL

空閑8個bytes

?

空閑字節(jié):? 8bytes。若用ASSM則需要在此+8字節(jié),否則不需要(未驗證)

?

00018060h

0

0

0

0

0

1

3

0

FF

FF

18

0

0E

8

F6

7

?

空閑

flag

ntab

nrow

frre

fsbo

fseo

avsp

?

struct kdbh ?14 bytes?????? @100??? :此結(jié)構(gòu)共14字節(jié),塊內(nèi)偏移量100字節(jié)

??? ub1 kdbhflag??????????? @100?? ?:N=pctfree hit(clusters); F=do not put on freelist; K=flushable cluster keys?

??? b1 kdbhntab???????????? @101?? ?:Number of tables (>1 in clusters)

??? b2 kdbhnrow???????????? @102??? :block 有多少條數(shù)據(jù)

??? sb2 kdbhfrre??????????? @104??? :First free row entry index; -1 = you have to add one

??? sb2 kdbhfsbo??????????? @106??? :空閑空間的開始

??? sb2 kdbhfseo??????????? @108??? :空閑空間的結(jié)尾

??? b2 kdbhavsp???????????? @110??? :塊中可用空閑空間,單位是bytes

??? b2 kdbhtosp???????????? @112??? :塊中總可用空間

?

00018070h

F6

7

0

0

3

0

BF

17

0E

8

E7

0F

3D

5A

7

52

?

kdbhtosp

kdbtoffs

kdbtnrow

rowoffs1

Rowoffs2

Rowoffs3

freespace

?

Table Directory ?Entry ?Structure

?

struct kdbt[1], 4 bytes???? @114???????

??? b2 kdbtoffs???????????? @114????

b2 kdbtnrow???????????? @116

?

Row Directory

?

sb2? kdbr[3] ???@118 : --共3(記錄條數(shù)為變量)條記錄,每個記錄長2 bytes ,塊內(nèi)偏移量118 bytes 。

?? ?row offs1

?? ?row offs2

?? ?row offs3

?

…….

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

?

freespace

?

ub1 freespace[2038]?? @124?? --共2038 bytes,塊內(nèi)偏移量124 bytes

???????????????????????????? --[2038] = kdbh.kdbhavsp(十進制)?

???????????????????????????? --@124 = kdbh.fsbo(十進制)+ ( 20 + 24 + 24*ITLS + 8 )

?

00018870h

0

0

2C

0

2

2

C1

4

FE

D0

7

61

20

20

20

20

?

freespace

flag

lock

ccnt

lgth

date

?

lgth

date

?

ub1 rowdata[6026] ???@2162? --共6026 bytes,塊內(nèi)偏移量2162 bytes

??????????????????????????? --@2162 =? ( 20 + 24 + 24*ITLS + 8 ) + kdbh.fsbo(十進制) + freespace[2038]

??????????????????????????? --注:本數(shù)據(jù)塊的起始位置 18000h( 十六進制文件的offset ),塊內(nèi)偏移量2162,故rowdata在本塊的最后一條(數(shù)據(jù)塊中的數(shù)據(jù)是從底? 向上增長的)數(shù)據(jù)位置為:00018872h 。實際上:此條數(shù)據(jù)已被刪除,select是查不到的,oracle并未從塊中立即清楚delete的數(shù)據(jù)。從dump文件中計算最后一行數(shù)據(jù)( 未被刪除的 )位置:0001904b h

?

00019040h

20

20

20

20

20

20

20

20

20

20

20

2c

0

2

1

80

00019050h

fe

D0

7

61

20

20

20

20

20

20

20

20

20

20

20

20

?

行記錄結(jié)構(gòu):

????? flag:? 1byte。行狀態(tài)標(biāo)志

????? lock:? 1byte。同ITL 的lck相對應(yīng) 表示這行是否被 lock 了

????? ccnt:? 1byte。該行數(shù)據(jù)幾列

????????????? 以上三個字節(jié)對應(yīng)kdrh結(jié)構(gòu)中的(ub1 kdrhflag,ub1 kdrhlock,ubl kdrhccnt)

????? Lgth:? 列的數(shù)據(jù)的長度是多少。

???????????? 1. 0xfa ( 250 bytes ) 其實0xfb,0xfc,0xfd 也同樣是250bytes

???????????? 2. 0xfe fb 00 ( 0xfb 00 表示的251 bytes 0xfe表示row的長度超過了250 bytes)

???????????? 3. 0xff 表示number 的 null 這也是oracle中null的表現(xiàn)形式排序的時候null最大了

??????????? 字段的數(shù)據(jù)超過250字節(jié)是就用3bytes來表示字段的長度。因為如果是long類型,它的字段再長

??????????? 它在這個block中的數(shù)據(jù)的長度不會超過64K 。所以最長用3bytes來表示行的長度已經(jīng)夠了.再長就鏈接行了

????? Data:? 實際字段值

?

?

…….

0

2c

0

2

2

C1

4

fe

D0

7

61

20

20

20

20

20

?

date

00019ff0h

20

20

20

20

20

20

20

20

20

20

20

20

3

6

8b

61

?

?

block tail

?

ub4 tailchk???? @8188? --塊尾部的4 bytes

???? 第1 byte : 對應(yīng)開始的 seq

???? 第2 byte : 對應(yīng)開始的 type

?? 第3,4 byte : 對應(yīng)開始的SCN的末2位

?

?

下面結(jié)合dump文件對數(shù)據(jù)塊進行分析:

The Cache Header

? .......

? Start dump data blocks tsn: 14 file#: 14 minblk 12 maxblk 12

? buffer tsn: 14 rdba: 0x0380000c (14/12)

? scn: 0x0000.0015618b seq: 0x03 flg: 0x04 tail: 0x618b0603

? frmt: 0x02 chkval: 0xaf9d type: 0x06=trans data

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

注:buffer tsn :14??? 這個記錄只是在dump文件中有記錄,在實際的block 中是沒有記錄的。

 

The Transaction Header

?

Block header dump:? 0x0380000c

?Object id on Block? Y

?seg/obj: 0xd004? csc: 0x00.15516a? itc: 2? flg: E? typ: 1 - DATA

???? brn: 0? bdba: 0x3800009 ver: 0x01 opc: 0

???? inc: 0? exflg: 0

注:brn,ver,inc,exflg 等字段在數(shù)據(jù)塊中未找到相應(yīng)字節(jié)

 

Itl?????????? Xid????????????????? Uba???????? Flag? Lck??????? Scn/Fsc

0x01?? 0x0003.005.00000274? 0x00800343.01a2.29? C---??? 0? scn 0x0000.001510ae

0x02?? 0x0002.00c.00000251? 0x00800a48.01d7.09? C---??? 0? scn 0x0000.0015143d

 

 

data_block_dump,data header at 0xc555a64

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

tsiz: 0x1f98??? ?--8k block: 8192-20(block head)-24(Transaction Header)-24*2(ITL)-8(空閑塊)-4(block tail)=8088(0x1f98)

hsiz: 0x18?????? -- Data header size? 數(shù)據(jù)塊頭20個字節(jié)+數(shù)據(jù)塊尾4個字節(jié)=24字節(jié)(0x14)????? ??????????  

pbl: 0x0c555a64? --Pointer to buffer holding the block?????????????????????????????  

 ?????????????????????????????????????????????????????  

注:tsiz,hsiz,pbl并未存儲在數(shù)據(jù)塊中????????????????????????????????????????  

 ?????????????????????????????????????????????????????  

bdba: 0x0380000c

76543210

flag=--------

ntab=1

nrow=3

frre=-1

fsbo=0x18???????????????????????? --空閑空間起始位置距離本塊頭的距離:? 0x18 + ( 20 + 24 + ITL*2 + 8 )

fseo=0x80e??????????????????????? --空閑空間結(jié)尾位置距離本塊頭的距離: 0x80e + ( 20 + 24 + ITL*2 + 8 )

avsp=0x7f6??????????????????????? --塊中可用空閑空間 avsp = fseo - fsbo

tosp=0x7f6??????????????????????? --塊中總可用空間

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

0x12:pri[0] offs=0x17bf?????????? --第1行行頭塊內(nèi)偏移字節(jié):0x17bf + ( 20 + 24 + ITL*2 + 8 )

0x14:pri[1] offs=0x80e

0x16:pri[2] offs=0xfe7??????????? --最后一條記錄塊內(nèi)偏移字節(jié):0xfe7+( 20 + 24 + ITL*2 + 8 ) (表格中說明:0001904b h)

block_row_dump:

tab 0, row 0, @0x17bf

tl: 2009 fb: --H-FL-- lb: 0x0? cc: 2

col? 0: [ 2]? c1 04

col? 1: [2000] 61 20 20……

tab 0, row 1, @0x80e

tl: 2009 fb: --H-FL-- lb: 0x0? cc: 2

col? 0: [ 2]? c1 04

col? 1: [2000] 61 20 20……

tab 0, row 2, @0xfe7

tl: 2008 fb: --H-FL-- lb: 0x0? cc: 2

col? 0: [ 1]? 80

col? 1: [2000] 61 20 20……

?

?

?文檔附件位置:http://www.itpub.net/thread-1820926-1-1.html

總結(jié)

以上是生活随笔為你收集整理的Oracle 摘去数据块的面纱的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。