Oracle bbed使用说明2---常用命令

一.BBED常用命令说明

先看帮助的说明
BBED> help all         
SET DBA [ dba | file#, block# ]
SET FILENAME 'filename'
SET FILE file#
SET BLOCK [+/-]block#
SET OFFSET [ [+/-]byte offset | symbol | *symbol ]
SET BLOCKSIZE bytes
SET LIST[FILE] 'filename'
SET WIDTH character_count
SET COUNT bytes_to_display
SET IBASE [ HEX | OCT | DEC ]
SET OBASE [ HEX | OCT | DEC ]
SET MODE  [ BROWSE | EDIT ]
SET SPOOL [ Y | N ]
SHOW [ <SET parameter> | ALL ]
INFO
MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]
DUMP[/v] [ DBA | FILENAME | FILE | BLOCK | OFFSET | COUNT ]
PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
</Nuf>:
N - a number which specifies a repeat count.
u - a letter which specifies a unit size:
  b - b1, ub1 (byte)
  h - b2, ub2 (half-word)
  w - b4, ub4(word)
  r - Oracle table/index row
f - a letter which specifies a display format:
  x - hexadecimal
  d - decimal
  u - unsigned decimal
  o - octal
  c - character (native)
  n - Oracle number
  t - Oracle date
  i - Oracle rowid
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
MODIFY[/x|d|u|o|c] numeric/character string
      [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
ASSIGN[/x|d|u|o] <target spec>=<source spec>
<target spec> : [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
<source spec> : [ value | <target spec options> ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]
POP [ALL]
REVERT [ DBA | FILE | FILENAME | BLOCK ]
UNDO
HELP [ <bbed command> | ALL ]
VERIFY [ DBA | FILE | FILENAME | BLOCK ]
CORRUPT [ DBA | FILE | FILENAME | BLOCK ]

BBED>


set 设定当前的环境
show 查看当前的环境参数,跟sqlplus的同名命令类似。
dump 列出指定block的内容
find 在指定的block中查找指定的字符串,结果是显示出字符串,及其偏移量--offset,偏移量就是在block中的字节数
modify 修改指定block的指定偏移量的值,可以在线修改。
copy 把一个block的内容copy到另一个block中
verify 检查当前环境是否有坏块
sum 计算block的checksum,modify之后block就被标识为坏块,current checksum与reqired checksum不一致,sum命令可以计算出新的checksum并应用到当前块。
undo 回滚当前的修改操作,如果手误做错了,undo一下就ok了,回到原来的状态。
revert 回滚所有之前的修改操作,意思就是 undo all

1.1 info

--显示当前可以进行browse或者edit 的file。即我们filelist( /u01/app/oracle/bbed/filelist.txt )里指定的datafile信息。

BBED> info
 File#  Name                                                        Size(blks)
 -----  ----                                                        ----------
     1  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_bc7ld3s       61440
     2  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_bc7ld       40320
     3  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_bc7lf4b       30720
     4  /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_bc7lflno         640

BBED>

1.2 show

显示当前的配置选项,注意当前文件及数据块

BBED> show
        FILE#           3
        BLOCK#          12
        OFFSET          0
        DBA             0x00c0000c (12582924 3,12)
        FILENAME        /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_bc7lf4bd_.dbf
        BIFILE          bifile.bbd
        LISTFILE        /u01/app/oracle/bbed/filelist.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No

BBED> 

1.3 set 命令

1.3.1 set file :根据文件号设置当前文件

BBED> set file 2
        FILE#           2

BBED> show
        FILE#           2  --当前文件
        BLOCK#          12 
        OFFSET          0
        DBA             0x0080000c (8388620 2,12)
        FILENAME        /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_bc7ldql4_.dbf
        BIFILE          bifile.bbd
        LISTFILE        /u01/app/oracle/bbed/filelist.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No

BBED> 

1.3.2 set block :指定当前文件中的块

BBED> set block 100
        BLOCK#          100

BBED> show
        FILE#           2
        BLOCK#          100
        OFFSET          0
        DBA             0x00800064 (8388708 2,100)
        FILENAME        /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_bc7ldql4_.dbf
        BIFILE          bifile.bbd
        LISTFILE        /u01/app/oracle/bbed/filelist.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No
        
BBED> set block +10
        BLOCK#          110
BBED>

1.3.3 set width :设定当前屏幕的宽度,默认是80.

BBED> set width 100
        WIDTH           100

BBED>

3.3.4 set mode  :设置bbed 的模式browse 或 edit。 browse 模式不允许进行修改。 如果要修改,就选择edit模式。这个在之前的配置文件bbed.par里,选择了edit。

BBED> set mode browse
        MODE            Browse

BBED> set mode edit
        MODE            Edit

BBED>

1.4 MAP  (参考:Oracle 摘去数据块的面纱

--Map会通过偏移量来显示block里的详细信息,如block header,data block header 和row directory。 使用/v 选项,可以查看更详细的信息。

--在不指定block的情况下,会显示当前block的信息,如果想显示其他block的信息,可以使用file name,file id,block 和DBA 来指定要显示的block。

BBED> map         --只显示当前块的部分信息
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252                                  Dba:0x01400cb4
------------------------------------------------------------
 KTB Data Block (Table/Cluster)
 struct kcbh, 20 bytes                      @0       --block header 信息
 struct ktbbh, 72 bytes                     @20      --事务信息
 struct kdbh, 14 bytes                      @100     --对应尾区部分
 struct kdbt[1], 4 bytes                    @114     --table directory *kdbt[0]指针显示值
 sb2 kdbr[333]                              @118     --row directory *kdbr[0]指针值显示状态flg
 ub1 freespace[4739]                        @784     --free space
 ub1 rowdata[2665]                          @5523    --row data (采用倒序排列,第一行在最下面)
 ub4 tailchk                                @8188    --tail check


BBED> 
 
 
BBED> map /v   -显示当前块的详细信息
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252                                  Dba:0x01400cb4
------------------------------------------------------------
 KTB Data Block (Table/Cluster)

 struct kcbh, 20 bytes                      @0       
    ub1 type_kcbh                           @0       
    ub1 frmt_kcbh                           @1       
    ub1 spare1_kcbh                         @2       
    ub1 spare2_kcbh                         @3       
    ub4 rdba_kcbh                           @4       
    ub4 bas_kcbh                            @8       
    ub2 wrp_kcbh                            @12      
    ub1 seq_kcbh                            @14      
    ub1 flg_kcbh                            @15      
    ub2 chkval_kcbh                         @16      
    ub2 spare3_kcbh                         @18      

 struct ktbbh, 72 bytes                     @20      
    ub1 ktbbhtyp                            @20      
    union ktbbhsid, 4 bytes                 @24      
    struct ktbbhcsc, 8 bytes                @28      
    b2 ktbbhict                             @36      
    ub1 ktbbhflg                            @38      
    ub1 ktbbhfsl                            @39      
    ub4 ktbbhfnx                            @40      
    struct ktbbhitl[2], 48 bytes            @44      

 struct kdbh, 14 bytes                      @100     
    ub1 kdbhflag                            @100     
    b1 kdbhntab                             @101     
    b2 kdbhnrow                             @102     
    sb2 kdbhfrre                            @104     
    sb2 kdbhfsbo                            @106     
    sb2 kdbhfseo                            @108     
    b2 kdbhavsp                             @110     
    b2 kdbhtosp                             @112     

 struct kdbt[1], 4 bytes                    @114     
    b2 kdbtoffs                             @114     
    b2 kdbtnrow                             @116     

 sb2 kdbr[333]                              @118     

 ub1 freespace[4739]                        @784     

 ub1 rowdata[2665]                          @5523    

 ub4 tailchk                                @8188    


BBED> 

 Map 显示的具体信息解释如下:

struct kcbh, 20 bytes

Block Header Structure

    ub1 type_kcbh

Block   type (see Header Block Types below)

    ub1 frmt_kcbh

Block   format 1=Oracle 7, 2=Oracle 8+

    ub1 spare1_kcbh

Not   used

    ub1 spare2_kcbh

Not   used

    ub4 rdba_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 ktbbhfsl

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[333]

Row Directory

ub1 freespace[4739]

Free Space

ub1 rowdata[2665]

Row Data

ub4 tailchk

(See Tailchecks below)

1.5 print (参考:Oracle 摘去数据块的面纱

   map命令只输出数据块的结构信息,print命令输出的信息比map更加详细。

   print其输出格式:UnitSize* | Name | Offset|  Value    -------自定义类型|名称|块内偏移量|值

示例:

--利用map输出数据块结构
BBED> set file 5
        FILE#           5
BBED> set block 3252
        BLOCK#          3252
BBED> map /v
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252                                  Dba:0x01400cb4
------------------------------------------------------------
 KTB Data Block (Table/Cluster)

 struct kcbh, 20 bytes                      @0       
    ub1 type_kcbh                           @0       
    ub1 frmt_kcbh                           @1       
    ub1 spare1_kcbh                         @2       
    ub1 spare2_kcbh                         @3       
    ub4 rdba_kcbh                           @4       
    ub4 bas_kcbh                            @8       
    ub2 wrp_kcbh                            @12      
    ub1 seq_kcbh                            @14      
    ub1 flg_kcbh                            @15      
    ub2 chkval_kcbh                         @16      
    ub2 spare3_kcbh                         @18      

 struct ktbbh, 72 bytes                     @20      
    ub1 ktbbhtyp                            @20      
    union ktbbhsid, 4 bytes                 @24      
    struct ktbbhcsc, 8 bytes                @28      
    b2 ktbbhict                             @36      
    ub1 ktbbhflg                            @38      
    ub1 ktbbhfsl                            @39      
    ub4 ktbbhfnx                            @40      
    struct ktbbhitl[2], 48 bytes            @44      

 struct kdbh, 14 bytes                      @100     
    ub1 kdbhflag                            @100     
    b1 kdbhntab                             @101     
    b2 kdbhnrow                             @102     
    sb2 kdbhfrre                            @104     
    sb2 kdbhfsbo                            @106     
    sb2 kdbhfseo                            @108     
    b2 kdbhavsp                             @110     
    b2 kdbhtosp                             @112     

 struct kdbt[1], 4 bytes                    @114     
    b2 kdbtoffs                             @114     
    b2 kdbtnrow                             @116     

 sb2 kdbr[333]                              @118     

 ub1 freespace[4739]                        @784     

 ub1 rowdata[2665]                          @5523    

 ub4 tailchk                                @8188    


--利用print输出ktbbh结构中的元素信息
BBED> print ktbbh
struct ktbbh, 72 bytes                      @20      
   ub1 ktbbhtyp                             @20       0x01 (KDDBTDATA)
   union ktbbhsid, 4 bytes                  @24      
      ub4 ktbbhsg1                          @24       0x0000c7d1
      ub4 ktbbhod1                          @24       0x0000c7d1
   struct ktbbhcsc, 8 bytes                 @28      
      ub4 kscnbas                           @28       0x0005f8f9
      ub2 kscnwrp                           @32       0x0000
   b2 ktbbhict                              @36       2
   ub1 ktbbhflg                             @38       0x32 (NONE)
   ub1 ktbbhfsl                             @39       0x00
   ub4 ktbbhfnx                             @40       0x01400c89
   struct ktbbhitl[0], 24 bytes             @44      
      struct ktbitxid, 8 bytes              @44      
         ub2 kxidusn                        @44       0x0002
         ub2 kxidslt                        @46       0x0019
         ub4 kxidsqn                        @48       0x000000f5
      struct ktbituba, 8 bytes              @52      
         ub4 kubadba                        @52       0x00804a72
         ub2 kubaseq                        @56       0x0082
         ub1 kubarec                        @58       0x0b
      ub2 ktbitflg                          @60       0xa000 (KTBFUPB, KTBFCOM)
      union _ktbitun, 2 bytes               @62      
         b2 _ktbitfsc                       @62       0
         ub2 _ktbitwrp                      @62       0x0000
      ub4 ktbitbas                          @64       0x0005f1dd
   struct ktbbhitl[1], 24 bytes             @68      
      struct ktbitxid, 8 bytes              @68      
         ub2 kxidusn                        @68       0x0002
         ub2 kxidslt                        @70       0x0022
         ub4 kxidsqn                        @72       0x000000f8
      struct ktbituba, 8 bytes              @76      
         ub4 kubadba                        @76       0x008090ac
         ub2 kubaseq                        @80       0x0085
         ub1 kubarec                        @82       0x1f
      ub2 ktbitflg                          @84       0x2001 (KTBFUPB)
      union _ktbitun, 2 bytes               @86      
         b2 _ktbitfsc                       @86       0
         ub2 _ktbitwrp                      @86       0x0000
      ub4 ktbitbas                          @88       0x000600bc

---输出其叶子节点信息
BBED> print ktbbh.ktbbhitl[0].ktbitxid.kxidusn
ub2 kxidusn                                 @44       0x0002

BBED>


 

1.6 dump

---dump命令可以讲block 的内容显示到屏幕。每次显示的bytes由count 控制,默认是512 bytes。使用 /v 选项,可以显示更多详细信息

BBED> dump /v dba 2,111 offset 0 count 128
 File: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_bc7ldql4_.dbf (2)
 Block: 111     Offsets:    0 to  127  Dba:0x0080006f
-------------------------------------------------------
 02a20000 6f008000 b6260400 00005d04 l ..o.......].
 38e80000 07002700 ae000000 48005c5c l 8...'...H.\\
 0000e81f 741f301f d01e8c1e 281ee41d l ..t.0...(.

                                                   801d1c1d d81c781c 341cd01b 8c1b281b l ....x.4...(.
 c41a801a 201adc19 78193419 d0186c18 l .. .x.4.l.
 2818c817 84172017 dc167816 1416d015 l (... .x...

                                                   70152c15 c8148414 2014bc13 78131813 l p.,... .x...
 d4127012 2c12c811 64112011 b8105410 l p.,.d. .T.

 <16 bytes per line>

BBED>

1.7 find

---可以用来搜索关键字。 可以从offset 0 搜索到top 或者从当前的offset 搜索到top

---find 命令支持的switch 类型如下表,注意,find 不支持number和Date

Switch

Datatype

/x

Hexadecimal

/d

Decimal

/u

unsigned decimal

/o

Octal

/c

character (native)

 

 

 

 

 

 

 

 

 

 

--查找文件及数据块编号
SQL> select 
  2       rowid,
  3       dbms_rowid.rowid_relative_fno(rowid) REL_FNO,--File id 数据库文件数少于1024时,REL_FNO与File id相同
  4       dbms_rowid.rowid_block_number(rowid) BLOCK_NO,--Block number
  5       dbms_rowid.rowid_row_number(rowid)   ROW_NO
  6  from tv.t01
  7  where name='zz';

ROWID                 REL_FNO   BLOCK_NO     ROW_NO
------------------ ---------- ---------- ----------
AAAMfRAAFAAAAy0AFM          5       3252        332

SQL> 


--设置当前文件及数据块
BBED> set file 5
        FILE#           5

BBED> set block 3252
        BLOCK#          3252

BBED> show
        FILE#           5
        BLOCK#          3252
        OFFSET          0
        DBA             0x01400cb4 (20974772 5,3252) ----0x01400cb4为rdba;0x01400cb4的十进制 20974772
        FILENAME        /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf
        BIFILE          bifile.bbd
        LISTFILE        /u01/app/oracle/bbed/filelist.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No
    

BBED> find /c zz top  --前面已经指定数据文件5和数据块3252
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252             Offsets: 5530 to 6041           Dba:0x01400cb4 --rdba
------------------------------------------------------------------------
 7a7a2c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 

 <32 bytes per line>

BBED>

BBED> dump /v offset 5530 count 128   --前面已经指定数据文件5和数据块3252
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252    Offsets: 5530 to 5657  Dba:0x01400cb4
-------------------------------------------------------
 7a7a2c00 02018002 79792c00 02018002 l zz,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....

 <16 bytes per line>

BBED> 

--结果显示的头两个字母就是zz

--如果我们要继续搜索zz,那么只需要按下f 就可以了,不需要跟参数。

BBED> f     
BBED-00212: search string not found  --我们的块里只有一个'zz'

BBED>

1.8 modify(m)

---用于改变块内的数据

---在file 5,block 3252 有'zz',我们这里把zz 改成ww。

BBED> set file 5
        FILE#           5

BBED> set block 3252
        BLOCK#          3252

BBED> show
        FILE#           5
        BLOCK#          3252
        OFFSET          0
        DBA             0x01400cb4 (20974772 5,3252)
        FILENAME        /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf
        BIFILE          bifile.bbd
        LISTFILE        /u01/app/oracle/bbed/filelist.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No

--更改前的数据
BBED> dump /v offset 5530 count 128
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252    Offsets: 5530 to 5657  Dba:0x01400cb4
-------------------------------------------------------
 7a7a2c00 02018002 79792c00 02018002 l zz,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....

 <16 bytes per line>

--开始更改
BBED> modify /c ww offset 5530 
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252             Offsets: 5530 to 5657           Dba:0x01400cb4
------------------------------------------------------------------------
 77772c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 

 <32 bytes per line>
 
--查看更改后的
BBED> dump /v offset 5530 count 128  
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252    Offsets: 5530 to 5657  Dba:0x01400cb4
-------------------------------------------------------
 77772c00 02018002 79792c00 02018002 l ww,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....

 <16 bytes per line>

BBED>

接下来使改变的值生效的命令sum

1.9 sum:使这些修改生效

BBED> sum dba 5,3252 apply
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Check value for File 5, Block 3252:
current = 0x5a3f, required = 0x5a3f

BBED>

--回到sql窗口,刷新缓存
SQL>  alter system set events = 'immediate trace name flush_cache';
或
SQL> alter system flush buffer_cache;

--查询
SQL> select * from tv.t01 where name='ww';

ID NAME
-- ----------
 1 ww

SQL>

注:下面对这些数据用SQL语句做相互转换

1)把表中的数据转成16进制(即在ORACLE内部数据块看到的数据),用以下sql语句:

SQL> select  dump('ww','16')  
  2  from dual;

DUMP('WW','16')
-------------------
Typ=96 Len=2: 77,77  --7777为'ww'的16进制值

SQL> 


2)反过来把16进制转成表中的数据(当然我这边的数据类型只考虑了number和varchar类型),用以sql下语句:
SQL> col id for 9  ---对number类型格式化。如果写成col id for a9,查询出的值为乱码(##########)
SQL> col name for a10
SQL> select 
  2     UTL_RAW.CAST_TO_NUMBER(replace('c102',' ')) id,
  3     UTL_RAW.CAST_TO_VARCHAR2(replace('77772c00',' ')) name
  4  from  dual;

ID NAME
-- ----------
 1 ww,

SQL> 

1.10 revert

--revert是恢复自bbed 启动以来的所有修改(包含被sum apply的数据)

--将'ww'改成'zz'
BBED> modify /c zz offset 5530
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252             Offsets: 5530 to 5657           Dba:0x01400cb4
------------------------------------------------------------------------
 7a7a2c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 

 <32 bytes per line>

--查看
BBED> dump /v offset 5530 count 128
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252    Offsets: 5530 to 5657  Dba:0x01400cb4
-------------------------------------------------------
 7a7a2c00 02018002 79792c00 02018002 l zz,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....

 <16 bytes per line>

--应用修改
BBED> sum dba 5,3252 apply
Check value for File 5, Block 3252:
current = 0x5732, required = 0x5732


--在sql窗口查看
SQL> select * from tv.t01 where name='zz';

ID NAME
-- ----------
 1 zz

SQL>

--revert是恢复自bbed 启动以来的所有修改
BBED> revert dba 5,3252  
All changes made to this block will be rolled back. Proceed? (Y/N) y
Reverted file '/u01/app/oracle/oradata/ORCL/datafile/test_01.dbf', block 3252

BBED> dump /v offset 5530 count 128
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252    Offsets: 5530 to 5657  Dba:0x01400cb4
-------------------------------------------------------
 77772c00 02018002 79792c00 02018002 l ww,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....
 79792c00 02018002 79792c00 02018002 l yy,.....yy,.....

 <16 bytes per line>

--应用修改
BBED> sum apply
Check value for File 5, Block 3252:
current = 0x5a3f, required = 0x5a3f

BBED> 

--在sql窗口查看
SQL> alter system set events = 'immediate trace name flush_cache';

System altered.

SQL> select * from tv.t01 where name='zz';

no rows selected

SQL> 

1.11 undo :回滚最后一次的操作

BBED> modify /c zz offset 5530
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252             Offsets: 5530 to 5657           Dba:0x01400cb4
------------------------------------------------------------------------
 7a7a2c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 

 <32 bytes per line>

--应用
BBED> sum apply
Check value for File 5, Block 3252:
current = 0x5732, required = 0x5732

--回滚,即使被应用的数据也会被回滚
BBED> undo
BBED> modify /x 7777 filename '/u01/app/oracle/oradata/ORCL/datafile/test_01.dbf' block 3252. offset 5530.
 File: /u01/app/oracle/oradata/ORCL/datafile/test_01.dbf (5)
 Block: 3252             Offsets: 5530 to 5657           Dba:0x01400cb4
------------------------------------------------------------------------
 77772c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 
 79792c00 02018002 79792c00 02018002 79792c00 02018002 79792c00 02018002 

 <32 bytes per line>


BBED> sum apply
Check value for File 5, Block 3252:
current = 0x5a3f, required = 0x5a3f

BBED>

1.12 corrupt

将一个block 标记为corrupt,这样db 在操作时就会跳过该block,从而避免错误

BBED> corrupt dba 5,3252
Block marked media corrupt.

BBED>

注意: undo 命令不能undo 一个corruption,但是revert 命令却可以

--整理自网络http://blog.csdn.net/tianlesoftware/article/details/5006580

 

posted @ 2015-01-16 15:49  PoleStar  阅读(1071)  评论(0编辑  收藏  举报