The oracle bbed (Oracle Block Browser and Editor) tool is an internal data Block-level viewing and modification tool provided by Oracle. With this tool, we can easily view the storage details at the block level of Oracle to better understand the technical details of Oracle Internal structure. First, we need to explain that BBED is a non-recommended tool for Oracle, it is only provided for internal recovery and use. It does not provide any external information or related technical support. Therefore, if we plan to use this tool, especially in the production environment, it is our final choice. It must be used when the backup can be recovered. Otherwise, the use of BBED may easily cause database startup failure or more serious problems. In the version provided by BBED, Only Linux/Unix is supported, and there is no corresponding version on Windows. The environment where indexes use BBED is usually in the command line mode. In addition, BBED does not provide a ready-to-use version in Oracle, so we need to manually compile the link. Oracle 10g bbed installation documentation [oracle @ test ~] $ Cd $ ORACLE_HOME/rdbms/lib [oracle @ test lib] $ ls www.2cto.com config. c ins_rdbms.mk ksnnt2.o rfsin. o sskfoded. oconfig. o jox. o ktd. o rfsxc. o sskrmed. ocursize. o joxoff. o kxmnsd. o s0exudrv. o sskrned. odbfsize. o kciwcx. o kxmwsd. o s0impdrv. o sskrsed. odefopt. o kcsm. o kzlnlbac. o s0kudbv. o ssoraed. odmndm. o kfod. o libdbtools10.a s0kuzr. o sstrced. odmndmse. o kgupc. o libdsga10.a s0kvpf. o strcpt. odmwdm. o kgutc. o Libknlopt. a s0udexp. o sulmain. odumpsga. o kkpoban. o libodm10.a s0udimp. o tg4pwd. oenv_rdbms.mk kkxntp. o libperfsrv10.a sbbdpt. o tstshm. ogenezi. o kxwtp. o libqsmashr. a shorm. o ttcoerr. ogenksms. o kopc. o libskgxns. a shou. o ttcsoi. ohoaoci. o kprnanotubes. o libskgxpd. a sjsex. o wpspldrv. ohoat. o kprwts. o libskgxpu. a skfedpt. o xaondy. ohoax. o kpucb. o libxdb. a skfodpt. o xaonsl. ohomts. o kpudfo. o mapsga. o skrmpt. o xs Noolap. ohormc. o kpundf. o maxmem. o skrnpt. o xsyeolap. ohormd. o ksms. o nmliblist skrspt. o ipvsdrv. ohorm. o ksnkcs. o opimai. o sllfls. ohormt. o ksnkkpo. o osh. o srfsd. ohout. o ksnktd. o rfscom. o ssbbded. ohsxaora. o ksnnni. o rfsd. o sskfeded. o [oracle @ test lib] $ pwd/opt/app/oracle/product/10g/rdbms/lib [oracle @ test lib] $ make-f ins_rdbms.mk $ ORACLE_HOME/rdbms/ lib/bbedLinking BBED utility (bbed) rm-f/opt/app/or Acle/product/10g/rdbms/lib/bbedgcc-o/opt/app/oracle/product/10g/rdbms/lib/bbed-L/opt/app/oracle/ product/10g/rdbms/lib/-L/opt/app/oracle/product/10g/lib/-L/opt/app/oracle/product/10g/lib /stubs/-L/usr/lib-www.2cto.com lirc/opt/app/oracle/product/10g/lib/s0main. o/opt/app/oracle/product/10g/rdbms/lib/ssbbded. o/opt/app/oracle/product/10g/rdbms/lib/sbbdpt. o 'cat/opt/app/oracle/product/10g/lib/ld Flags '-lnsslb10-lncrypt10-lnsgr10-lnzjs10-ln10-lnnz10-lnl10/opt/app/oracle/product/10g/rdbms/lib/defopt. o-ldbtools10-lclntsh 'cat/opt/app/oracle/product/10g/lib/ldflags '-lnsslb10-lncrypt10-lnsgr10-lnzjs10-ln10-lnnz10-lnl10-ro10' cat/opt/app/oracle/product/10g/lib/ldflags '-lnsslb10-lncrypt10-lnsgr10-lnzjs10-ln10-lnnz10-lnl10-lclient10-lnnetd10-lvsn10-lcommon10-lgener Ic10-lmm-lsnls10-lnls10-lcore10-lsnls10-lnls10-lcore10-lsnls10-lnls10-lxml10-lcore10-lunls10-lsnls10-lnls10-lcore10-lnls10 'cat/opt/app/oracle/product/ 10g/lib/ldflags '-lnsslb10-lncrypt10-lnsgr10-lnzjs10-ln10-lnnz10-lnl10-lnro10 'cat/opt/app/oracle/product/10g/lib/ldflags '-lnsslb10-lncrypt10-lnsgr10-lnzjs10-ln10-lnnz10-lnl10-lclient10-lnnetd10-lvsn10-lcommon10-lge Neric10-extract-lnls10-lcore10-extract-lnls10-lcore10-extract-lnls10-lxml10-lcore10-lunls10-extract-lnls10-lcore10-lnls10-lclient10-extract-lvsn10-extract- lgeneric10-Example-lnls10-lcore10-lsnls10-lnls10-lcore10-Example-lnls10-lxml10-lcore10-lunls10-Example-lnls10-lcore10-lnls10 'cat/opt/app/oracle/ product/10g/lib/sysliblist '-Wl, -www.2cto.com rpath,/opt/app /Oracle/product/10g/lib-lm 'cat/opt/app/oracle/product/10g/lib/sysliblist '-ldl-lm-L/opt/app/ oracle/product/10g/lib [oracle @ test lib] $ [oracle @ test lib] $ cp bbed $ ORACLE_HOME/bin [oracle @ test lib] $ ls-l bbed [oracle @ test bin] $ pwd/opt/app/oracle/product/10g/bin [oracle @ test bin] $ cat file.txt 1/opt/app/oracle/oradata/wolf /system01.dbf 5033164802/opt/app/oracle/oradata/wolf/undotbs01.dbf 262144003 /Opt/app/oracle/oradata/wolf/sysaux01.dbf 2516582404/opt/app/oracle/oradata/wolf/users01.dbf 52428805/opt/app/oracle/oradata/wolf/wolfblock01.dbf 104857600 [oracle @ test bin] $ cat bbed.txt blocksize = 8192 listfile =/opt/app/oracle/product/10g/bin/file.txt mode = edit [oracle @ test bin] $ [oracle @ test bin] $. /bbed parfile =/opt/app/oracle/product/10g/bin/bbed.txt Password: (the Password here is blockedit) BBED: Release 2.0.0. 0.0-Limited Production on Monday July 16 03:01:57 2012 Copyright (c) 1982,200 5, Oracle. All rights reserved .*************!!! For Oracle Internal Use only !!! * ************** BBED> help allSET DBA [dba | file #, block #] set filename 'filename' set file file # set block [+/-] block # set offset [[+/-] byte offset | symbol | * symbol] set blocksize bytesSET LIST [FILE] 'filename' set width character_countSET COUNT bytes_to_displaySET IBASE [HEX | OCT | DEC] set obase [HEX | OCT | DEC] set mode [BROWSE | EDIT] set spool [Y | N] SHOW [<SET parameter> | ALL] INFO www.2cto.com 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 rowf-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 rowidFIND [/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] UNDOHELP [<bbed command> | ALL] VERIFY [DBA | FILE | FILENAME | BLOCK] upt [DBA | FILE | FILENAME | BLOCK] BBED> set filename '/opt/app/oracle/oradata/wolf/wolfblock01.dbf' FILENAME/opt/app/oracle/oradata/wolf/wolfblock01.dbfBBED> install BBED under www.2cto.com oracle 11g is not available in 11g but you can still link it after getting the following filesfrom any previous version like 10gR2. copy $ ORA10g_HOME/rdbms/lib/ssbbded. o to $ ORA11g_HOME/rdbms/libCopy $ ORA10g_HOME/rdbms/lib/sbbdpt. o to $ ORA11g_HOME/rdbms/libMessage files (list may differ): Copy $ ORA10g_HOME/rdbms/mesg/bbedus. msb to $ ORA11g_HOME/rdbms/mesgCopy $ ORA10g_HOME/rdbms/mesg/bbedus. msg to $ ORA11g_HOME/rdbms/mesgCopy $ ORA10g_HOME/rdbms/mesg/bbedar. msb to $ ORA11g_HOME/rdbms/mesgIssue the following command: make-f $ ORA11g_HOME/rdbms/lib/ins_rdbms.mk BBED = $ ORACLE_HOME/bin/bbed $ ORA11g_HOME/bin/bbedpassword: blockedit Experiment 1 uses bbed recovery (this experiment cannot be imitated) to search for 377 blockSQL> select segment_name, file_id, block_id from dba_extents where block_id = 377; SEGMENT_NAME specify FILE_ID BLOCK_ID ---------- BOOTSTRAP $1 377_SYSSMU3 $2 377I_DIR $ INSTANCE_JOB_NAME 3 377 SQL> select * from bootstrap $ where rownum <2; LINE # OBJ # ---------- SQL _TEXT example-1-18.0.0.0.0 www.2cto.com SQL> update bootstrap $ set SQL _text = '9. 0.0.0.0 'where line # =-1; 1 row updated. SQL> commit; Commit complete. SQL> select * from bootstrap $ where rownum <2; LINE # OBJ # ---------- SQL _TEXT failed-1-19.0.0.0.0SQL> shutdown immediateDatabase closed. database dismounted. ORACLE instance shut down. SQL> startupORACLE instance started. total System Global Area 285212672 bytesFixed Size 1218992 bytesVariable Size 104859216 bytesDatabase Buffers 176160768 bytesRedo Buffers 2973696 bytesDatabase mounted. ORA-01092: ORACLE instance terminated. disconnection forced view log [root @ test bdump] # tail-f alert_wolf.log SMON: enabling cache recoveryMon Jul 16 03:55:39 2012 Errors in file/opt/app/oracle/admin/wolf/udump/wolf_ora_21_2.trc: ORA-00704: bootstrap process failureORA-00702: bootstrap verison '9. 0.0.0.0 'inconsistent with version' 8. 0.0.0.0 'mon Jul 16 03:55:39 2012 Error 704 happened during db open, shutting down databaseUSER: terminating instance due to error 704 Instance terminated by USER, pid = 22.162ora-1092 signalled: alter database open... in this step www.2cto.com, follow the book's modified BBED> modify/c "8" offset 1276 File:/opt/app/oracle/oradata/wolf/system01.dbf (1) Block: 378 Offsets: 1276 to 1284 Dba: 0x0040017a 000038000000 00000000 00 <32 bytes per line> BBED> verifyDBVERIFY-Verification startingFILE =/opt/app/oracle/oradata/wolf/system01.dbfBLOCK = 378 Block 378 is corrupt0000upt block relative dba: 0x0040017a (file 0, block 378) Bad check value found during verificationData in bad block: type: 6 format: 2 rdba: 0x0040017a last change scn: 0x0000. 00087dc5 seq: 0x1 flg: 0x06 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x7dc50601 check value in block header: 0x0000f computed block checksum: 0x138 DBVERIFY-Verification completeTotal Blocks Examined: 1 Total Blocks Processed (Data): 0 Total Blocks Failing (Data): 0 Total Blocks Processed (Index ): 0 Total Blocks Failing (Index): 0 Total Blocks Empty: 0 Total Blocks Marked Blocks upt: 1 Total Blocks Influx: 0 BBED> sum apply www.2cto.com Check value for File 1, Block 378: current = 0x1347, required = 0x1347BBED> verifyDBVERIFY-Verification startingFILE =/opt/app/oracle/oradata/wolf/system01.dbfBLOCK = 378 DBVERIFY-Verification completeTotal Blocks Examined: 1 Total Blocks Processed (Data): 1 Total Blocks Failing (Data): 0 Total Blocks Processed (Index): 0 Total Blocks Failing (Index): 0 Total Blocks Empty: 0 Total Blocks Marked primary upt: 0 Total Blocks Influx: 0SQL> startupORACLE instance started. total System Global Area 285212672 bytesFixed Size 1218992 bytesVariable Size 104859216 bytesDatabase Buffers 176160768 bytesRedo Buffers 2973696 bytesDatabase mounted. database opened. SQL> select * from bootstrap $ where rownum 2 <2; LINE # OBJ # ---------- SQL _TEXT placement-1-18.0.0.0.0 SQL> www.2cto.com Experiment 2 SQL> select name from v $ datafile; NAME users/opt/app/oracle/oradata/wolf/system01.dbf/opt/app/oracle/oradata/wolf/undotbs01.dbf/opt/app/oracle/oradata/wolf/sysaux01.dbf/opt /app/oracle/oradata/wolf/users01.dbf/opt/app/oracle/oradata/wolf/wolfblock01.dbfSQL> select file #, name from v $ datafile; FILE # ---------- NAME limit 1/opt/app/oracle/oradata/wolf/system01.dbf 2/opt/app/oracle/oradata/wolf/undotbs01.dbf 3/opt/app/oracle/oradata /wolf/sysaux01.dbf FILE # ---------- NAME limit 4/opt/app/oracle/oradata/wolf/users01.dbf 5/opt/app/oracle/oradata/wolf/wolfblock01.dbf SQL> drop table wolfblock; table dropped. SQL> create table wolfblock (id number) tablespace wolfblock; Table created. SQL> insert into wolfblock values (1); 1 row created. SQL>/1 row created. SQL>/1 row created. SQL>/1 row created. SQL> select * from wolfblock; ID ---------- 1 1 1 1 www.2cto.com SQL> select rowid, round (rowid) rel_fno, dbms_rowid.rowid_block_number (rowid) blockno from wolfblock; ROWID REL_FNO BLOCKNO blocks ---------- AAAMj + AAFAAAAAXAAA 5 23 AAAMj + Route 5 23 AAAMj + AAFAAAAAXAAC 5 23 AAAMj + Route 5 23SQL> alter system dump datafile 5 block 23; System altered. the results after dump and bbed are quite small, but complex. The author yujin2010good