标签:
先看帮助的说明 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
--显示当前可以进行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>
显示当前的配置选项,注意当前文件及数据块
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.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>
--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/o1_mf_undotbs1_bc7ldql4_.dbf (2)
Block: 111 Dba:0x0080006f
------------------------------------------------------------
Undo Data
struct kcbh, 20 bytes @0
struct ktubh, 200 bytes @20
ub1 freespace[36] @220
ub1 undodata[7932] @256
ub4 tailchk @8188
BBED> map /v -显示当前块的详细信息
File: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_bc7ldql4_.dbf (2)
Block: 111 Dba:0x0080006f
------------------------------------------------------------
Undo Data
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 ktubh, 200 bytes @20
struct ktubhxid, 8 bytes @20
ub2 ktubhseq @28
ub1 ktubhcnt @30
ub1 ktubhirb @31
ub1 ktubhicl @32
ub1 ktubhflg @33
ub2 ktubhidx[93] @34
ub1 freespace[36] @220
ub1 undodata[7932] @256
ub4 tailchk @8188
BBED>
---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>
---可以用来搜索关键字。 可以从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) 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 ------------------------------------------------------------------------ 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>
---用于改变块内的数据
---在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
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>
--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>
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>
将一个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
标签:
原文地址:http://www.cnblogs.com/polestar/p/4228949.html