Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4006251
  • 博文数量: 536
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(536)

文章存档

2024年(3)

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(252)

2006年(73)

分类: Oracle

2007-11-01 11:41:43

近来在Itpub上看到AnySQL的Mydul的第一版本的源码, http://www.itpub.net/858109.html 学习中。其实好多地方不是很明白, java也不是很熟悉, 格式不是很了解, 很多Oracle的功能也不熟悉。慢慢学习中。。。

与这个相关的东西还有 ITpub grassbell 斑主在 2004-07-27 一篇Oracle Data Block物理结构的文章 http://epub.itpub.net/9/9.htm, 好早啊, 那时我还在学校,什么Oracle几乎没什么接触。 不想那么多了, 就想弄明白,哪怕已经很过时了。

我使用英文的google查询了一下找到这个篇文章


这个应该比较全面的了:
下面的内容主要来源 orafaq 的Oracle Data block格式的小节, 不是很具体:

Oracle Data Block Format

=================
struct kcbh, 20 bytes               Block Header Structure
    ub1 type_kcbh                   Block Type
                                    Different block types are designated by
                                    the first byte of the block.
                                    
                                    01  Undo segment header
                                    02  Undo data block
                                    03  Save undo header
                                    04  Save undo data block
                                    05  Data segment header(temp, index,
                                        data and so on)
                                    06  KTB managed data block(with ITL)
                                    07  Temp table data block(no ITL)
                                    08  Sort Key
                                    09  Sort Run
                                    10  Segment free list block
                                    11  Data file header
                                   
    ub1 frmt_kcbh                   Block format
                                    1   Oracle 7
                                    2   Oracle 8+
                                   
    ub1 spare1_kcbh                 Not used
    ub1 spare2_kcbh                 Not used
    ub4 rbda_kcbh                   RDBA - Relative Data Block Address
    ub4 bas_kcbh                    SCN Base
    ub2 wrp_kcbh                    SCN Wrap
    ub1 seq_kcbh                    Sequence number, incremented for every
                                      change made to the block at the same SCN

    ub1 flg_kcbh                    Flag:
                                    0x01    New Block
                                    0x02    Delayed Logging Change
                                            advanced SCN/seq
                                    0x04    Check value saved - block
                                            XOR's to zero
                                    0x08    Temporary block

    ub2 chkval_kcbh                 Optional block checksum (if
                                      DB_BLOCK_CHECKSUM = TRUE)

    ub2 spare3_kcbh                 Not used

------------------
struct ktbbh, 72 bytes              Transaction Fixed Header Structure
    ub1 ktbbhtyp                    Block type
                                    1   Data
                                    2   Index
    union ktbbhsid, 4 bytes         Segment / Object ID
    struct ktbbhcsc, 8 bytes        SCN at last block cleanout
    b2 ktbbhict                     Number of ITL slots
    ub1 ktbbhflg                    0 = on the freelist
    ub1 ktbbhfs1                    ITL TX freelist slot
    ub4 ktbbhfnx                    DBA of next block on the freelist
    struct ktbbhitl[2], 48 bytes    ITL list index

-------------------
struct kdbh, 14 bytes               Data Header Structure
    ub1 kdbhflag                    N = pctfree hit(clusters);
                                    F = do not put on freelist;
                                    K = flushable cluster keys
    b1 kdbhntab                     Number of tables (> 1 in clusters)
    b2 kdbhnrow                     Number of rows
    sb2 kdbhfrre                    First free row entry index;
                                    -1 = you have to add one
    sb2 kdbhfsbo                    Freespace begin offset
    sb2 kdbhfseo                    Freespace end offset
    b2 kdbhavsp                     Available space in the block
    b2 kdbhtosp                     Total available space when all TXs commit

--------------------
struct kdbt[1], 4 bytes             Table Directory Entry Structure
    b2 kdbtoffs
    b2 kdbtnrow

--------------------
sb2 kdbr[1]                         Row Directory
ub1 freespace[8030]                 Free Space
ub1 rowdata[38]                     Row Data
ub4 tailchk                        
   
Tailchecks:
The tail of an Oracle 8+ block is a concatenation of the lower order two bytes of the SCN base, the block type and the SCN sequence number.
E.g. if the SCN base number is 0x00029728, the block type is 06 and the SCN sequence number is 0x02, the tail check would be 0x97280602:

SCN base        Type    SCN seq
9728            06      02

Although this tail check value is generated from three components. Oracle treats the final value as a single unsigned integer stored as a word(4 bytes). On little-endian architecture machines, which include Intel, the value will be stores as low-order byte first.
阅读(3791) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~