Sample output from a 10.2.0.1 installation
is shown below. The reason for showing it is
to illustrate the difference between Oracle
versions 9 and 10 in the flags. Put another
way, there is no guarantee that one can take
BBED from one version and use it on another
version, but one is welcome to try.
[oracle@oralinux lib]$
make -f ins_rdbms.mk
$ORACLE_HOME/rdbms/lib/BBED
To confirm the creation, see if the BBED
executable was created. In this example, the
make command was executed in the rdbms/lib
directory. BBED can be placed anywhere the
DBA likes. Also, change the permissions if
needed.
-rwxr-xr-x
1 oracle
dba
434057 Aug 25 16:26 BBED
To confirm that the utility actually runs,
invoke it. This example uses the 10g
version, which shows release 2.0.0.0.0, and
so does the 9.0.4 version. Aside from the
change in the copyright, the release does
not appear to have changed in quite some
time.
[oracle@oralinux lib]$
./BBED
Password:
BBED: Release
2.0.0.0.0 - Limited Production on Wed
Aug 27 16:17:06 2015
Copyright (c) 1982,
2005, Oracle.
All rights reserved.
************* !!! For
Oracle Internal Use only !!!
***************
BBED>
Note that one will be prompted for a
password. Virtually all of the references to
BBED via a search on the Internet mention
that if one is motivated enough to be using
BBED in the first place, then one is clever
enough to determine the password on your
own. The password is blockedit. It will be
seen as BLOCKEDIT in a hex dump file of BBED.
Use xxd in /usr/bin to create a dump of BBED,
and then look for 'BBED>' in the file. A few
lines up is BLOCKEDIT.
The mileage may vary, but it is possible to
use BBED.EXE that shipped with Oracle 8.1.6,
which was about the last time the Windows
version was included in the RDBMS software
installation, and use that executable
against later versions of Oracle datafiles.
Before going into syntax and examples, some
preliminaries are in order.
First and foremost is this: BBED is
an undocumented and unsupported, from a
customer's perspective, utility. Unless
being directed to use this tool by Oracle
Support, the DBA is on his own. Do not use
BBED on a production database unless one
knows what one is doing. Do not use BBED on
any database that one cannot afford to lose.
Take a backup of any database on which this
tool is going to be used.
If the DBA needs to recover data and finds
herself completely stymied by every other
effort made so far, this is the last resort.
There may be bigger and better tools out
there, but the "here and now" tool is BBED.
If this tool is needed to
save/rescue/recover a production database,
it would be in the DBA�s best interest to
first take a cold backup and then take a
copy of that backup as the test bed. In
other words, do the work on files separate
from the actual files. If the DBA is trying
to restore data, transfer it from a rescue
instance back into the production instance.
Oracle documentation for BBED, to include
looking for it on MetaLink, or My Oracle
Support as it is now known, is almost
nowhere to be found in the public domain.
MetaLink note 62015.1 contains (assuming it
still exists within OSS) a note that 'BBED is a SUPPORT ONLY tool
and should NOT be discussed with customers.'
The contents of the note are available
inside a mailing list, and support
agreements prevent publishing it within this
book. (See
http://www.freelists.org/post/oracle-l/is-it-the-bbed )
Nonetheless, information can be gleaned
about this tool and others as well from the
message library that accompanies Oracle
software. $ORACLE_HOME/rdbms/mesg
contains a file named BBEDus.msg. One can
cat or vi the file and peruse its contents
to obtain an idea of how the tool works.
Within the message library towards the end
is a listing of valid positional parameters,
one of which is HELP. Windows installations
of Oracle still contain the message library
even though BBED.EXE is no longer included.
Before one starts working directly with
BBED, it is helpful to know one's way around
data blocks in general including how to get
internal block information by row within a
table. That and other pieces of information
commonly needed include the absolute file
number, the full path and name of datafiles,
datafile size in blocks, data block address,
block number, block size, and the block
type.
The DBA needs a reporting tool to output
information about a block. There is more
than one way to get this information, but
the easiest is based on using the supplied
PL/SQL built-in named DBMS_ROWID.
This package with ten functions and one
procedure has been available since at least
the Oracle8i days, but use of it may be new
to the DBA. Information from several
functions is combined in the one procedure
which makes use of OUT parameters. Create
one's own wrapper procedure around
DBMS_ROWID.ROWID_INFO to make it reusable.
The analyst named Scott in the EMP table is
going to be promoted to manager. The steps to
alter the table data outside of SQL*Plus are:
1.
Get the ROWID if it is not already known
2.
Shutdown the database and take a cold backup
3.
Start bbed with a parameter file, being sure to
include the relevant datafile
4.
Find the data block address
5.
Find the offset where the string ANALYST begins
and confirm the data/location
6.
Change the mode to edit unless the parfile
already includes that
7.
Modify the data
8.
Confirm the data change
9.
Apply the change
10.
Restart the database and look for the change
The chosen approach is that one already knows
some things about the data, e.g., the record
that one wants to change and the ROWID/dba
information.
The dba will still be 4,32 for this
example.
After shutting down the database and taking a
cold backup while using the same parfile from
before, a bbed session can be started. After it
is started, navigate to dba 4,32 and set the
offset to 0 so the DBA sees that she has a known
starting position for the search/find operation
to follow.
[oracle@oralinux bbed]$
bbed parfile=bbed.par
Password:
BBED: Release 2.0.0.0.0 -
Limited Production on Sun Aug 31 17:55:58 2015
Copyright (c) 1982, 2005,
Oracle.
All rights reserved.
************* !!! For
Oracle Internal Use only !!! ***************
BBED> set dba 4,32
DBA
0x01000020 (16777248 4,32)
BBED> set offset 0
OFFSET
0
The find command will dump multiple lines. Since
one is searching for a character string, use the
c flag.
BBED> find /c SCOTT
File:
/opt/app/oracle/oradata/ORCL2/users01.dbf
(4)
Block:
32
Offsets: 7864 to 8191
Dba:0x01000020
------------------------------------------------------------------------
53434f54
5407414e 414c5953 5403c24c 430777bb 04130101
0102c21f ff02c115
2c010803
c24e5305 434c4152 4b074d41 4e414745 5203c24f
280777b5 06090101
0103c219
33ff02c1 0b2c0108 03c24d63 05424c41 4b45074d
414e4147 455203c2
4f280777
b5050101 010103c2 1d33ff02 c11f2c01 0803c24d
37064d41 5254494e
0853414c
45534d41 4e03c24d 630777b5 091c0101 0103c20d
3302c20f 02c11f2c
010803c2
4c43054a 4f4e4553 074d414e 41474552 03c24f28
0777b504 02010101
03c21e4c
ff02c115 2c010803 c24c1604 57415244 0853414c
45534d41 4e03c24d
630777b5
02160101 0103c20d 3302c206 02c11f2c 010803c2
4b640541 4c4c454e
0853414c
45534d41 4e03c24d 630777b5 02140101 0102c211
02c20402 c11f2c01
0803c24a
4605534d 49544805 434c4552 4b03c250 030777b4
0c110101 0102c209
ff02c115
1006dbbf
<32
bytes per line>
Dump the current offset and confirm that SCOTT
was found.
BBED> dump /v dba 4,32
offset 7864 count 32
File:
/opt/app/oracle/oradata/ORCL2/users01.dbf
(4)
Block:
32
Offsets: 7864 to 7895
Dba:0x01000020
-------------------------------------------------------
53434f54
5407414e 414c5953 5403c24c l
SCOTT.ANALYST.?
430777bb
04130101 0102c21f ff02c115 l C.w?......?..?
<16
bytes per line>
The output tells the DBA that SCOTT begins at
offset 7864 within the dba. Counting over six
positions is where ANALSYT should begin. To
confirm this, move the offset (explicitly,
although one can add or subtract positions, such
as +4 or -3) to 7870 and dump the contents
again.
BBED> set offset 7870
OFFSET
7870
BBED> d /v
File:
/opt/app/oracle/oradata/ORCL2/users01.dbf
(4)
Block:
32
Offsets: 7870 to 7901
Dba:0x01000020
-------------------------------------------------------
414e414c
59535403 c24c4307 77bb0413 l ANALYST.?C.w?..
01010102
c21fff02 c1152c01 0803c24e l
....?..?,...?
<16
bytes per line>
Note the syntax used in the last dump command.
If one is not sure of the location, one can
always set it as done in the first dump. Now it
is time to replace ANALYST with MANAGER, and
that is done via the modify command. Now modify
it and dump to confirm the change. Modifications
can be made via one of several formats (same as
find), so the easiest case for readability is
finding and modifying via character strings, and
that is what the /c does. Do not forget to
change the EDIT mode if necessary (BBED> set
mode edit).
BBED> modify /c MANAGER
Warning: contents of
previous BIFILE will be lost. Proceed? (Y/N)
Y
File:
/opt/app/oracle/oradata/ORCL2/users01.dbf
(4)
Block:
32
Offsets: 7870 to 7901
Dba:0x01000020
------------------------------------------------------------------------
4d414e41
47455203 c24c4307 77bb0413 01010102 c21fff02
c1152c01 0803c24e
<32
bytes per line>
BBED> d /v
File:
/opt/app/oracle/oradata/ORCL2/users01.dbf
(4)
Block:
32
Offsets: 7870 to 7901
Dba:0x01000020
-------------------------------------------------------
4d414e41
47455203 c24c4307 77bb0413 l MANAGER.?C.w?..
01010102
c21fff02 c1152c01 0803c24e l
....?..?,...?
<16
bytes per line>
Now perform a sum, which is used to check or set
the block's checksum value, and apply the
change.
BBED> sum
Check value for File 4,
Block 32:
current = 0x26b5, required
= 0x32ae
BBED> sum apply
Check value for File 4,
Block 32:
current = 0x32ae, required
= 0x32ae
So far, so good. Assuming the change has been
made in the data block, name two ways one knows
of right now to check the value
but not
using the dump command. One is using SQL*Plus,
but within bbed, one could print the row data.
SCOTT's row number is still 8 (or 7 recalling
that bbed starts at 0), so a combination of the
following could be used:
BBED> p *kdbr[7]
rowdata[235]
------------
ub1 rowdata[235]
@7856
0x2c
BBED> x /rnccntnnn
rowdata[235]
@7856
------------
flag@7856: 0x2c (KDRHFL,
KDRHFF, KDRHFH)
lock@7857: 0x01
cols@7858:
8
col
0[3] @7859: 7788
col
1[5] @7863: SCOTT
col
2[7] @7869: MANAGER
col
3[3] @7877: 7566
col
4[7] @7881: 19-APR-87
col
5[2] @7889: 3000
col
6[0] @7892: *NULL*
col
7[2] @7893: 20