-oracle数据库恢复-Raid5数据恢复-RAID0数据恢复ORACLE优化与疑难问题讨论区 → oracle 得number date 类型在数据文件BLOCK中得存储格式


  共有2139人关注过本帖树形打印

主题:oracle 得number date 类型在数据文件BLOCK中得存储格式

oracle数据恢复-RAID5数据恢复-raid数据恢复
sosdb
  1楼 个性首页 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


数据恢复 恢复数据
等级:超级版主 帖子:809 积分:10386 威望:0 精华:1 注册:2007-1-28 11:50:49
oracle 得number date 类型在数据文件BLOCK中得存储格式  发帖心情 Post By:2007-4-23 16:23:35



----------------------------------------
| 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。)


1. 操作系统(Unix)上dump


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 offs=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的情况




www.sosdb.com 专业数据库恢复

oracle数据恢复raid数据恢复

qq:9417901

msn:glkgdj@hotmail.com

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部

返回版面帖子列表

oracle 得number date 类型在数据文件BLOCK中得存储格式








签名