您的位置:CNOUG博客首页 » George Daily Note » 日志
数据块dump
上一篇 / 下一篇 2007-02-08 09:29:40 / 个人分类:blog
数据块dump
--------------------------------------------------------------------------------
首先在确定要dump的block在哪个数据文件上,是block_id是多少。可以通过dba_extents视图或rowid等信息得到。
Restricted Rowid
----------------------------------------
| BBBBBBBB . RRRR . FFFF |
------------------------------------------
/ / /
| | |
| | --------------------File Number
| ------------------------------Row Number
--------------------------------------------Block NumberOracle 8 Rowid
------------------------------------------------
| OOOOOO . FFF . BBBBBB . SSS |
------------------------------------------------
/ / / /
| | | |
| | | -----------Slot Number(Row#)
| | ----------------------Block Number
| --------------------------------Relative File Number
----------------------------------------------Data Object Numberrowid的定义规则,第7~9位是表示的是数据文件,而10~15位表示的是在这个数据文件中的第几个BLOCK。
rowid编码相当于64进制。用A~Z a~z 0~9 + /共64个字符表示。A表示0,B表示1,……,a表示26,……,0表示52,……,
+表示62,/表示63。)
dd bs=<db_block_size> if=<file_name> | skip=(block-1) count=1 | od -x
2. 数据库级的dump
alter system dump datafile <file_id> block <block_id>
3. dump结果的说明
Block header dump: 0x01000316 <---- Relative Data Block Address
Object id on Block? Y
seg/obj: 0x16cb csc: 0x00.2b506360 itc: 1 flg: - typ: 1 - DATA
^ ^ ^ ^ ^
| | | | ------typ: 1 = DATA 2 = INDEX
| | | --------------flg: O = On Freelist
| | ---------------------itc: Number of ITL slots
| ----------------------------------csc: SCN of last block cleanout
------------------------------------------------Seg/Obj ID in Dictionary
fsl: 0 fnx: 0x0 ver: 0x01
^ ^
| --------------------------------------------DBA of next block on freelist
----------------------------------------------------ITL TX freelist slot
Itl Xid Uba Flag Lck Scn/Fsc
0x01 xid: 0x0002.04c.0003c689 uba: 0x0081744b.43e1.25 --U- 285 fsc 0x0000.2b506537==> Itl ITL Index No.(No of ITLS determined by INITRANS and MAXTRANS)
==> Xid Transaction ID(Undo Seg.Slot.Wrap)
==> Uba Undo Adderss(Undo DBA.SeqNo.RecordNo)
==> Flag C=Committed U=Committed Upper Bound T=Active at CSC
B=Rollback of this UBA gives before image of ITL
Flag combinations include:
CB-- Tx is Committed ,rollback of this UBA gives prev ITL
------ Active Tx - look at RBS header to see if really active
--U- Upper Bound Commit
==> Lck Number of Rows affected by this transaction
==> Scn/Fsc Scn=SCN of commited TX, Fsc=Free Space Credit(bytes)
Fsc overlaps the SCN Wrap when present
data_block_dump
===============
tsiz: 0x1fb8 ==>Total data area size
hsiz: 0x24c ==>Data header size
pbl: 0x1101cb044 ==>Pointer to buffer holding the block
bdba: 0x01000316 ==>Block relative data block address(RDBA)
flag=----------- ==>N=pctfree hit(Clusters),
F=Don't put on freelist
K=flushable cluster keys
ntab=1 ==>Number of tables(>1 in cluster)
nrow=285 ==>Number of ROWS
frre=-1 ==>First free row index entry.
-1=you have to add one
fsbo=0x24c ==>Free Space Begin offset
fseo=0x582 ==>Free Space End offset
avsp=0x336 ==>Available space in the block
tosp=0x336 ==>Total available space when all TXs commit
0xe:pti[0] nrow=285 ōffs=0 ==>Number of ROWS for first table
block_row_dump:
tab 0, row 0, @0x94f ==> table 0, row 0 offset
tl: 32 fb: --H-FL-- lb: 0x1 cc: 2
^ ^ ^ ^
| | | ------Number of columns in this ROW piece
| | -------------Lock byte - ITL entry that has this row locked
| ------------------------Flag byte: H: Head of row piece , K: Cluster key
| C: Cluster table member, D: Deleted row,
| F: First data piece,L: Last data piece,
| P: First column cintinues from previous row
| N:Last column cintinues in next piece
--------------------------------Row Size(header + data)
col 0: [ 4] c3 03 3d 07
col 1: [23] 44 42 4d 53 5f 41 51 5f 53 59 53 5f 45 58 50 5f 41 43 54 49 4f 4e 53
4.利用dump函数来dump:
Date(长度 7 类型 12)
col dump_date form a35col real_date form a35
select dump(last_ddl_time) dump_date, to_char(last_ddl_time,'yyyy-mm-dd hh24:mi:ss') real_date
from user_objects
where rownum=1;
DUMP_DATE REAL_DATE
----------------------------------- ---------------------
Typ=12 Len=7: 120,102,4,13,16,48,53 2002-04-13 15:47:52世纪 120 - 100 = 20 世纪和年份加100后存储
年份 102 - 100 = 2
月份 4 月份和日期按原值存储
日期 13
小时 16 - 1 = 15 时间均加1后存储
分钟 48 - 1 = 47
秒 53 - 1 = 52
--------------------------------------------------------------------------------
Number(类型 2)
<[长度]>,符号位/指数 数字1,数字2,数字3,......,数字20
正数:指数=数字1 - 193 (最高位为1是代表正数)
负数:指数=62 - 第一字节
数字1是最高有效位
正数:加1存储
负数:被101减,如果总长度小于21个字节,最后加一个102(是为了排序的需要)
所存储的数值计算方法为:
把下面计算的结果加起来:
每个数字乘以100^(指数-N) (N是有效位数的顺序位,第一个有效位的N=0)
例:
select dump(123456.789) from dual;
DUMP(123456.789)
-------------------------------
Typ=2 Len=6: 195,13,35,57,79,91 指数 195 - 193 = 2
数字1 13 - 1 = 12 *1002-0 120000
数字2 35 - 1 = 34 *1002-1 3400
数字3 57 - 1 = 56 *1002-2 56
数字4 79 - 1 = 78 *1002-3 .78
数字5 91 - 1 = 90 *1002-4 .009
123456.789
select dump(-123456.789) from dual;
DUMP(-123456.789)
----------------------------------
Typ=2 Len=7: 60,89,67,45,23,11,102指数 62 - 60 = 2(最高位是0,代表为负数)
数字1 101 - 89 = 12 *1002-0 120000
数字2 101 - 67 = 34 *1002-1 3400
数字3 101 - 45 = 56 *1002-2 56
数字4 101 - 23 = 78 *1002-3 .78
数字5 101 - 11 = 90 *1002-4 .009
123456.789(-)
现在再考虑一下为什么在最后加102是为了排序的需要,-123456.789在数据库中实际存储为
60,89,67,45,23,11
而-123456.78901在数据库中实际存储为
60,89,67,45,23,11,91
可见,如果不在最后加上102,在排序时会出现-123456.789<-123456.78901的情况
相关阅读:
- 工作经验 (qiaoruzhi78, 2006-12-09)
- 有点激动 (xzs_calous, 2007-1-16)
- 对autotrace的补充 (qiaoruzhi78, 2007-1-18)
- 对autotrace的补充 (qiaoruzhi78, 2007-1-18)
- 关于db_file_multiblock_read_count 参数 (qiaoruzhi78, 2007-1-18)
- nologging的使用说明 (qiaoruzhi78, 2007-1-20)
- 关于os认证和口令文件认证 (qiaoruzhi78, 2007-1-23)
- 一些系统参数的说明 (qiaoruzhi78, 2007-1-23)
- Oracle中模拟及修复数据块损坏 (qiaoruzhi78, 2007-2-05)
- Oracle中Buffer Cache内存结构及监控 (qiaoruzhi78, 2007-2-07)
TAG: blog
