使用BBED理解和修改Oracle数据块

1.生成bbed list file文件:

SQL> select file#||' '||name||' '||bytes from v$datafile;
$ vim dbfile.txt
1 /u01/app/oradata/sydb/system01.dbf 754974720
2 /u01/app/oradata/sydb/sysaux01.dbf 587202560
3 /u01/app/oradata/sydb/undotbs01.dbf 429916160
4 /u01/app/oradata/sydb/users01.dbf 13107200
5 /disk2/oradata/sydb/tbs01.dbf 1816133632
6 /disk2/oradata/sydb/tbs02.dbf 119537664
7 /disk2/oradata/sydb/tbs03.dbf 20971520
8 /tmp/tbs_tmp.dbf 10485760

2.生成bbed参数文件:

$ vim bbed.par
mode=edit
listfile= dbfile.txt
blocksize=8192

3.创建测试表和数据:

create table tt1 (id number,name varchar2(30)) tablespace tbs03;
insert into tt1 values(1,'AAAA');
insert into tt1 values(2,'BBBB');
commit;

4.查询表数据行所在的数据块号:

select
  dbms_rowid.rowid_block_number(rowid) blocknum,
  dbms_rowid.ROWID_RELATIVE_FNO(rowid) fileNo,
  id,name
  from tt1;
BLOCKNUM    FILENO        ID NAME
---------- ---------- ---------- ------------------------------
      135          7          1 AAAA
      135          7          2 BBBB

5.使用bbed:

$ bbed parfile=bbed.par
Password:  ==>blockedit is default password of bbed
BBED: Release 2.0.0.0.0 - Limited Production on Tue Mar 31 20:39:29 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set filename '/disk2/oradata/sydb/tbs03.dbf' block 135
        FILENAME        /disk2/oradata/sydb/tbs03.dbf
        BLOCK#          135
BBED> map
 File: /disk2/oradata/sydb/tbs03.dbf (0)
 Block: 135                                  Dba:0x00000000
------------------------------------------------------------
 KTB Data Block (Table/Cluster)
 struct kcbh, 20 bytes                      @0      =>数据块头
 struct ktbbh, 72 bytes                    @20    =>事物层
 struct kdbh, 14 bytes                      @100  =>数据层
 struct kdbt[1], 4 bytes                    @114  ==>表目录层
 sb2 kdbr[2]                                @118    ==>行目录层
 ub1 freespace[8044]                        @122    ==>空闲空间
 ub1 rowdata[22]                            @8166    ==>实际行数据
 ub4 tailchk                                @8188    ==>校验码

使用BBED理解和修改Oracle数据块

使用print打印数据块结构信息PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]

BBED> print kcbh
struct kcbh, 20 bytes                      @0     
  ub1 type_kcbh                            @0        0x06  ==>块类型(参考下图:Block Type)
  ub1 frmt_kcbh                            @1        0xa2  ==>块格式
  ub1 spare1_kcbh                          @2        0x00  ==>保留空间
  ub1 spare2_kcbh                          @3        0x00  ==>保留空间
  ub4 rdba_kcbh                            @4        0x01c00087  ==>块地址
  ub4 bas_kcbh                            @8        0x002fa91a  ==>base SCN
  ub2 wrp_kcbh                            @12      0x0000      ==>wrap SCN
  ub1 seq_kcbh                            @14      0x01      ==>SCN 序列
  ub1 flg_kcbh                            @15      0x06 (KCBHFDLC, KCBHFCKV)  ==> 块属性(0x01 新块,0x02我的理解是延迟修改的块,0x04检查保存的块,0x08 Temporary block)
  ub2 chkval_kcbh                          @16      0xe534  ==>校验码,它的值取决于参数(db_block_checksum)的设置值
  ub2 spare3_kcbh                          @18      0x0000  ==>保留空间

BlockTypeNumber

 

BlockType

 

01

 

Undo segment header

 

02

 

Undo data block

 

03

 

Save undo header

 

04

 

Save undo data block

 

05

 

Data segment header

 

06

 

Trans data,KTB manager 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

 

(:Block Type)

打印具体结构值:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5b6a0dc8105a4ddf2eca22fd02a14cb8.html