*****************************BBED***********************************
--bbed is short for block browser and edit, an oracle tool that is intended for
--oracle internal use only.
--[1].install bbed
--[2].bbed login
--[3].configure bbed before use
--[4].test bbed configuration
--[5].prepare for the test
--[6].example #1 - Changing Data
--[7].expampe #2 - Recovering Delterd Rows
--bbed is short for block browser and edit, an oracle tool that is intended for
--oracle internal use only.
--[1].install bbed
--[2].bbed login
--[3].configure bbed before use
--[4].test bbed configuration
--[5].prepare for the test
--[6].example #1 - Changing Data
--[7].expampe #2 - Recovering Delterd Rows
--[1].install bbed
[oracle@ora10 ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@ora10 lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
Linking BBED utility (bbed)
rm -f /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/bbed
gcc -o /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/bbed -L/u01/app/oracle/
product/10.2.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/10.2.0/dbhome_1/lib
/ -L/u01/app/oracle/product/10.2.0/dbhome_1/lib/stubs/ /u01/app/oracle/product/
10.2.0/dbhome_1/lib/s0main.o /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/s
sbbded.o /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/sbbdpt.o `cat /u01/ap
p/oracle/product/10.2.0/dbhome_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -
lnzjs10 -ln10 -lnnz10 -lnl10 /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/d
efopt.o -ldbtools10 -lclntsh `cat /u01/app/oracle/product/10.2.0/dbhome_1/lib/l
dflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `
cat /u01/app/oracle/product/10.2.0/dbhome_1/lib/ldflags` -lnsslb10 -lncrypt10
-lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10
-lgeneric10 -lmm -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10
-lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/ap
p/oracle/product/10.2.0/dbhome_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -
lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/dbhome_
1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -l
client10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10 -lcore10
-lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -l
nls10 -lcore10 -lnls10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsn
ls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore
10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/app/oracle/product/10.
2.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/10.2.0/dbhome_1/
lib -lm `cat /u01/app/oracle/product/10.2.0/dbhome_1/lib/sysliblist` -ldl -lm
-L/u01/app/oracle/product/10.2.0/dbhome_1/lib
rm -f /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/bbed
gcc -o /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/bbed -L/u01/app/oracle/
product/10.2.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/10.2.0/dbhome_1/lib
/ -L/u01/app/oracle/product/10.2.0/dbhome_1/lib/stubs/ /u01/app/oracle/product/
10.2.0/dbhome_1/lib/s0main.o /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/s
sbbded.o /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/sbbdpt.o `cat /u01/ap
p/oracle/product/10.2.0/dbhome_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -
lnzjs10 -ln10 -lnnz10 -lnl10 /u01/app/oracle/product/10.2.0/dbhome_1/rdbms/lib/d
efopt.o -ldbtools10 -lclntsh `cat /u01/app/oracle/product/10.2.0/dbhome_1/lib/l
dflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `
cat /u01/app/oracle/product/10.2.0/dbhome_1/lib/ldflags` -lnsslb10 -lncrypt10
-lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10
-lgeneric10 -lmm -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10
-lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/ap
p/oracle/product/10.2.0/dbhome_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -
lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/dbhome_
1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -l
client10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10 -lcore10
-lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -l
nls10 -lcore10 -lnls10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsn
ls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore
10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/app/oracle/product/10.
2.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/10.2.0/dbhome_1/
lib -lm `cat /u01/app/oracle/product/10.2.0/dbhome_1/lib/sysliblist` -ldl -lm
-L/u01/app/oracle/product/10.2.0/dbhome_1/lib
[oracle@ora10 lib]$ ls -l bbed
-rwxr-xr-x 1 oracle oinstall 541166 Dec 15 10:38 bbed
-rwxr-xr-x 1 oracle oinstall 541166 Dec 15 10:38 bbed
--copy bbed tool to directory bin,so the user oracle can use it anywhere.
[oracle@ora10 lib]$ cp bbed $ORACLE_HOME/bin
[oracle@ora10 lib]$ cp bbed $ORACLE_HOME/bin
--[2].bbed login
[oracle@ora10 lib]$ bbed
Password: <= the default password is “blockedit”
Password: <= the default password is “blockedit”
BBED: Release 2.0.0.0.0 - Limited Production on Sat Dec 15 10:50:55 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED>
--[3].configure bbed before use
--until then we have finished bbed install.To use bbed we need some other configuration.
--prarmeter file and filelist
--parameter file : a file which include the bbed default settings
--filelist : a file which will list all of the files to edit
--to get a filelist from your database use follow method
[oracle@ora10 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 15 12:31:33 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
12:31:33 sys@PROD> set heading off
12:31:38 sys@PROD> set echo off
12:31:41 sys@PROD> set feed off
12:31:45 sys@PROD> set trimspool on
12:31:52 sys@PROD> spool filelist.log
12:32:08 sys@PROD> select file#||' '||name||' '||bytes from v$datafile;
--until then we have finished bbed install.To use bbed we need some other configuration.
--prarmeter file and filelist
--parameter file : a file which include the bbed default settings
--filelist : a file which will list all of the files to edit
--to get a filelist from your database use follow method
[oracle@ora10 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 15 12:31:33 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
12:31:33 sys@PROD> set heading off
12:31:38 sys@PROD> set echo off
12:31:41 sys@PROD> set feed off
12:31:45 sys@PROD> set trimspool on
12:31:52 sys@PROD> spool filelist.log
12:32:08 sys@PROD> select file#||' '||name||' '||bytes from v$datafile;
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx8_.dbf 503316480
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 251658240
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
12:32:15 sys@PROD> spool off
12:32:18 sys@PROD> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 251658240
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
12:32:15 sys@PROD> spool off
12:32:18 sys@PROD> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
--edit filelist.log
[oracle@ora10 ~]$ vi filelist.log
[oracle@ora10 ~]$ vi filelist.log
--to get filelist.log like follows
[oracle@ora10 ~]$ cat filelist.log
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx8_.dbf 503316480
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 251658240
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
[oracle@ora10 ~]$ cat filelist.log
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx8_.dbf 503316480
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 251658240
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
--make a parameter file
[oracle@ora10 ~]$ vi bbed.par
[oracle@ora10 ~]$ cat bbed.par
blocksize=8192 <= database blocksize
listfile=/home/oracle/filelist.log <= path of filelist that will list all of the file to edit
mode=edit <= set the bbed mode to edit so that we can change data blocks
[oracle@ora10 ~]$ vi bbed.par
[oracle@ora10 ~]$ cat bbed.par
blocksize=8192 <= database blocksize
listfile=/home/oracle/filelist.log <= path of filelist that will list all of the file to edit
mode=edit <= set the bbed mode to edit so that we can change data blocks
--[4].test bbed configuration
[oracle@ora10 ~]$ bbed
Password:
[oracle@ora10 ~]$ bbed
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Sat Dec 15 12:49:58 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set listfile 'filelist.log' <= input your filelist name
LISTFILE filelist.log
LISTFILE filelist.log
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx 61440
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7 3840
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mx 30720
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14 2240
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh98 12800
6 /tmp/TBS01_1DBF 1280
--[5].prepare for the test
12:55:20 sys@PROD> create tablespace bbed datafile'/u01/app/oracle/oradata/PROD/datafile/bbed01.dbf' size 50m;
Tablespace created.
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx 61440
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7 3840
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mx 30720
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14 2240
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh98 12800
6 /tmp/TBS01_1DBF 1280
--[5].prepare for the test
12:55:20 sys@PROD> create tablespace bbed datafile'/u01/app/oracle/oradata/PROD/datafile/bbed01.dbf' size 50m;
Tablespace created.
12:56:58
sys@PROD> create user bbed identified by bbed default tablespace bbed;
User created.
User created.
12:57:30
sys@PROD> grant connect,resource to bbed;
Grant succeeded.
Grant succeeded.
12:59:30
bbed@PROD> create table presidents
13:00:15 2 (name varchar2(30),
13:00:43 3 start_year varchar2(20),
13:01:04 4 end_year varchar2(20))
13:01:23 5 /
13:00:15 2 (name varchar2(30),
13:00:43 3 start_year varchar2(20),
13:01:04 4 end_year varchar2(20))
13:01:23 5 /
Table created.
13:02:27
bbed@PROD> insert into presidents values('Dwight Eisnehower','1953','1961');
1 row created.
13:02:36
bbed@PROD> insert into presidents values('John Kennedy','1961','1963');
1 row created.
13:03:40
bbed@PROD> commit;
Commit complete.
13:03:50
bbed@PROD> select * from presidents;
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisnehower 1953 1961
John Kennedy 1961 1963
--------------------------------------------- -------------------- --------------------
Dwight Eisnehower 1953 1961
John Kennedy 1961 1963
--[6].example #1 Changing Data
--to modify data in an oracle data file using bbed
--to view the test table
13:04:02 bbed@PROD> select * from presidents;
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisnehower 1953 1961
John Kennedy 1961 1963
--------------------------------------------- -------------------- --------------------
Dwight Eisnehower 1953 1961
John Kennedy 1961 1963
--identify rows position
select rowid,
dbms_rowid.rowid_object(rowid) object_id,
dbms_rowid.rowid_relative_fno(rowid) file_id,
dbms_rowid.rowid_block_number(rowid) block_id ,
dbms_rowid.rowid_row_number(rowid) num ,
rowidtochar(rowid) from presidents
/
ROWID OBJECT_ID FILE_ID BLOCK_ID NUM ROWIDTOCHAR(ROWID)
------------------ ---------- ---------- ---------- ---------- ------------------
AAAM1MAAHAAAAAMAAA 52556 7 12 0 AAAM1MAAHAAAAAMAAA
AAAM1MAAHAAAAAMAAB 52556 7 12 1 AAAM1MAAHAAAAAMAAB
select rowid,
dbms_rowid.rowid_object(rowid) object_id,
dbms_rowid.rowid_relative_fno(rowid) file_id,
dbms_rowid.rowid_block_number(rowid) block_id ,
dbms_rowid.rowid_row_number(rowid) num ,
rowidtochar(rowid) from presidents
/
ROWID OBJECT_ID FILE_ID BLOCK_ID NUM ROWIDTOCHAR(ROWID)
------------------ ---------- ---------- ---------- ---------- ------------------
AAAM1MAAHAAAAAMAAA 52556 7 12 0 AAAM1MAAHAAAAAMAAA
AAAM1MAAHAAAAAMAAB 52556 7 12 1 AAAM1MAAHAAAAAMAAB
--all rows in the table presidents are in the file 7 block 12
--configure bbed to point to this block
[oracle@ora10 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 15 13:18:34 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
13:18:34
sys@PROD> set heading off
13:18:55 sys@PROD> set echo off
13:19:02 sys@PROD> set feed off
13:19:07 sys@PROD> set trimspool on
13:19:12 sys@PROD> spool filelist.log
13:19:17 sys@PROD> select file#||' '||name||' '||bytes from v$datafile;
13:18:55 sys@PROD> set echo off
13:19:02 sys@PROD> set feed off
13:19:07 sys@PROD> set trimspool on
13:19:12 sys@PROD> spool filelist.log
13:19:17 sys@PROD> select file#||' '||name||' '||bytes from v$datafile;
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx8_.dbf 503316480
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 262144000
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
7 /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf 52428800
13:19:25 sys@PROD> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 262144000
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
7 /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf 52428800
13:19:25 sys@PROD> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
[oracle@ora10 ~]$ vi filelist.log
[oracle@ora10 ~]$ cat filelist.log
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx8_.dbf 503316480
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 262144000
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
7 /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf 52428800
[oracle@ora10 ~]$ cat filelist.log
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx8_.dbf 503316480
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7n0k_.dbf 31457280
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mxq_.dbf 262144000
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14_.dbf 18350080
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh985h_.dbf 104857600
6 /tmp/TBS01_1DBF 10485760
7 /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf 52428800
[oracle@ora10 ~]$ bbed
Password:
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Sat Dec 15 13:20:22 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set listfile 'filelist.log'
LISTFILE filelist.log
LISTFILE filelist.log
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx 61440
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7 3840
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mx 32000
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14 2240
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh98 12800
6 /tmp/TBS01_1DBF 1280
7 /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf 6400 <= 用来测试的数据文件
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/PROD/datafile/o1_mf_system_85vh7mx 61440
2 /u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_85vh7 3840
3 /u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_85vh7mx 32000
4 /u01/app/oracle/oradata/PROD/datafile/o1_mf_users_85vh7n14 2240
5 /u01/app/oracle/oradata/PROD/datafile/o1_mf_example_85vh98 12800
6 /tmp/TBS01_1DBF 1280
7 /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf 6400 <= 用来测试的数据文件
BBED> set dba 7,12
DBA 0x01c0000c (29360140 7,12)
DBA 0x01c0000c (29360140 7,12)
BBED> find /c Dwight
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8161 to 8191 Dba:0x01c0000c <= offsets 8161 to 8191
------------------------------------------------------------------------
44776967 68742045 69736e65 686f7765 72043139 35330431 39363101 06886e
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8161 to 8191 Dba:0x01c0000c <= offsets 8161 to 8191
------------------------------------------------------------------------
44776967 68742045 69736e65 686f7765 72043139 35330431 39363101 06886e
<32 bytes per line>
--use dump to verify the data
--use dump to verify the data
BBED> dump /v dba 7,12 offset 8161 count 64
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8161 to 8191 Dba:0x01c0000c
-------------------------------------------------------
44776967 68742045 69736e65 686f7765 l Dwight Eisnehowe
72043139 35330431 39363101 06886e l r.1953.1961...n
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8161 to 8191 Dba:0x01c0000c
-------------------------------------------------------
44776967 68742045 69736e65 686f7765 l Dwight Eisnehowe
72043139 35330431 39363101 06886e l r.1953.1961...n
<16 bytes per line>
--because the Dwight start at 8161,then Eisnehower should start at 8168.
--we can user dump command to ensure this
BBED> dump /v dba 7,12 offset 8168 count 64
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
-------------------------------------------------------
4569736e 65686f77 65720431 39353304 l Eisnehower.1953. <= before Risnehower there is no data
31393631 0106886e l 1961...n
--because the Dwight start at 8161,then Eisnehower should start at 8168.
--we can user dump command to ensure this
BBED> dump /v dba 7,12 offset 8168 count 64
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
-------------------------------------------------------
4569736e 65686f77 65720431 39353304 l Eisnehower.1953. <= before Risnehower there is no data
31393631 0106886e l 1961...n
<16 bytes per line>
--use modify command to modify Eisnehower to Eisenhower.
--use modify command to modify Eisnehower to Eisenhower.
BBED> set mode edit
MODE Edit
MODE Edit
BBED> modify /c Eisen dba 7,12 offset 8170
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8170 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
45697365 6e776572 04313935 33043139 36310106 886e
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8170 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
45697365 6e776572 04313935 33043139 36310106 886e
<32 bytes per line>
--use dump command to verify
BBED> dump /v dba 7,12 offset 8168 count 64
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
-------------------------------------------------------
45694569 73656e77 65720431 39353304 l EiEisenwer.1953.
31393631 0106886e l 1961...n
--use dump command to verify
BBED> dump /v dba 7,12 offset 8168 count 64
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
-------------------------------------------------------
45694569 73656e77 65720431 39353304 l EiEisenwer.1953.
31393631 0106886e l 1961...n
<16 bytes per line>
--we make a wrong offset,modify again
BBED> modify /c senho dba 7,12 offset 8170
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8170 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
73656e68 6f776572 04313935 33043139 36310106 886e
--we make a wrong offset,modify again
BBED> modify /c senho dba 7,12 offset 8170
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8170 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
73656e68 6f776572 04313935 33043139 36310106 886e
<32 bytes per line>
BBED> dump /v dba 7,12 offset 8168 count 64
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
-------------------------------------------------------
45697365 6e686f77 65720431 39353304 l Eisenhower.1953.
31393631 0106886e l 1961...n
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
-------------------------------------------------------
45697365 6e686f77 65720431 39353304 l Eisenhower.1953.
31393631 0106886e l 1961...n
<16 bytes per line>
--apply changes
BBED> sum dba 7,12 apply
Check value for File 7, Block 12:
current = 0xc4c3, required = 0xc4c3
--apply changes
BBED> sum dba 7,12 apply
Check value for File 7, Block 12:
current = 0xc4c3, required = 0xc4c3
13:08:22
bbed@PROD> select * from presidents;
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisnehower <= not modify,why? 1953 1961
John Kennedy 1961 1963
--------------------------------------------- -------------------- --------------------
Dwight Eisnehower <= not modify,why? 1953 1961
John Kennedy 1961 1963
--it's from buffer cache,not from the disk.We flush the bufffer cache.
13:43:33 bbed@PROD> conn / as sysdba
Connected.
13:43:50 sys@PROD> alter system flush buffer_cache;
13:43:33 bbed@PROD> conn / as sysdba
Connected.
13:43:50 sys@PROD> alter system flush buffer_cache;
System altered.
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower <= been modified 1953 1961
John Kennedy 1961 1963
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower <= been modified 1953 1961
John Kennedy 1961 1963
--[7].expampe #2 - Recovering Delterd Rows
14:42:51
bbed@PROD> insert into presidents values('Jefferson Clinton','1993','2001');
1 row created.
1 row created.
14:43:03
bbed@PROD> commit;
Commit complete.
Commit complete.
14:43:06
bbed@PROD> select * from presidents;
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower 1953 1961
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower 1953 1961
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
14:43:06
bbed@PROD> select * from presidents;
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower 1953 1961
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower 1953 1961
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
14:43:15
bbed@PROD> delete from presidents where name='Dwight Eisenhower';
1 row deleted.
1 row deleted.
14:46:16
bbed@PROD> commit;
Commit complete.
Commit complete.
14:46:19
bbed@PROD> select * from presidents;
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
select rowid,
dbms_rowid.rowid_object(rowid) object_id,
dbms_rowid.rowid_relative_fno(rowid) file_id,
dbms_rowid.rowid_block_number(rowid) block_id ,
dbms_rowid.rowid_row_number(rowid) num ,
rowidtochar(rowid) from presidents
/
ROWID OBJECT_ID FILE_ID BLOCK_ID NUM ROWIDTOCHAR(ROWID)
------------------ ---------- ---------- ---------- ---------- ------------------
AAAM1MAAHAAAAAMAAB 52556 7 12 1 AAAM1MAAHAAAAAMAAB
AAAM1MAAHAAAAAMAAC 52556 7 12 2 AAAM1MAAHAAAAAMAAC
dbms_rowid.rowid_object(rowid) object_id,
dbms_rowid.rowid_relative_fno(rowid) file_id,
dbms_rowid.rowid_block_number(rowid) block_id ,
dbms_rowid.rowid_row_number(rowid) num ,
rowidtochar(rowid) from presidents
/
ROWID OBJECT_ID FILE_ID BLOCK_ID NUM ROWIDTOCHAR(ROWID)
------------------ ---------- ---------- ---------- ---------- ------------------
AAAM1MAAHAAAAAMAAB 52556 7 12 1 AAAM1MAAHAAAAAMAAB
AAAM1MAAHAAAAAMAAC 52556 7 12 2 AAAM1MAAHAAAAAMAAC
14:47:40
bbed@PROD> conn / as sysdba
Connected.
14:47:48 sys@PROD> alter system dump datafile 7 block 12;
System altered.
Connected.
14:47:48 sys@PROD> alter system dump datafile 7 block 12;
System altered.
14:48:15
sys@PROD> oradebug setmypid
Statement processed.
14:48:25 sys@PROD> oradebug tracefile_name
/u01/app/oracle/admin/prod/udump/ora10_ora_29185.trc
14:48:33 sys@PROD> !vi /u01/app/oracle/admin/prod/udump/ora10_ora_29185.trc
Statement processed.
14:48:25 sys@PROD> oradebug tracefile_name
/u01/app/oracle/admin/prod/udump/ora10_ora_29185.trc
14:48:33 sys@PROD> !vi /u01/app/oracle/admin/prod/udump/ora10_ora_29185.trc
Start dump data blocks tsn: 8 file#: 7 minblk 12 maxblk 12
buffer tsn: 8 rdba: 0x01c0000c (7/12)
scn: 0x0000.0009786a seq: 0x02 flg: 0x02 tail: 0x786a0602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x000000000A1A9400 to 0x000000000A1AB400
00A1A9400 0000A206 01C0000C 0009786A 02020000 [........jx......]
00A1A9410 00000000 00000001 0000CD4C 00097868 [........L...hx..]
00A1A9420 00000000 00320002 01C00009 00270008 [......2.......'.]
00A1A9430 00000146 00800081 001100DF 001D2001 [F............ ..]
00A1A9440 0009786A 000F0006 00000142 008006FB [jx......B.......]
00A1A9450 00350126 00008000 00097826 00000000 [&.5.....&x......]
00A1A9460 00000000 00030100 0018FFFF 1F281F40 [............@.(.]
00A1A9470 00001F47 1F790003 1F401F5F 00000000 [G.....y._.@.....]
00A1A9480 00000000 00000000 00000000 00000000 [................]
Repeat 497 times
00A1AB3A0 00000000 1103002C 6666654A 6F737265 [....,...Jefferso]
00A1AB3B0 6C43206E 6F746E69 3931046E 32043339 [n Clinton.1993.2]
00A1AB3C0 2C313030 4A0C0300 206E686F 6E6E654B [001,...John Kenn]
00A1AB3D0 04796465 31363931 36393104 03013C33 [edy.1961.1963<..>00A1AB3E0 69774411 20746867 65736945 776F686E [.Dwight Eisenhow] <= 值还在,但是已经标记删除了,所以查不到。
00A1AB3F0 31047265 04333539 31363931 786A0602 [er.1953.1961..jx]
Block header dump: 0x01c0000c
Object id on Block? Y
seg/obj: 0xcd4c csc: 0x00.97868 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00009 ver: 0x01 opc: 0
inc: 0 exflg: 0
buffer tsn: 8 rdba: 0x01c0000c (7/12)
scn: 0x0000.0009786a seq: 0x02 flg: 0x02 tail: 0x786a0602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x000000000A1A9400 to 0x000000000A1AB400
00A1A9400 0000A206 01C0000C 0009786A 02020000 [........jx......]
00A1A9410 00000000 00000001 0000CD4C 00097868 [........L...hx..]
00A1A9420 00000000 00320002 01C00009 00270008 [......2.......'.]
00A1A9430 00000146 00800081 001100DF 001D2001 [F............ ..]
00A1A9440 0009786A 000F0006 00000142 008006FB [jx......B.......]
00A1A9450 00350126 00008000 00097826 00000000 [&.5.....&x......]
00A1A9460 00000000 00030100 0018FFFF 1F281F40 [............@.(.]
00A1A9470 00001F47 1F790003 1F401F5F 00000000 [G.....y._.@.....]
00A1A9480 00000000 00000000 00000000 00000000 [................]
Repeat 497 times
00A1AB3A0 00000000 1103002C 6666654A 6F737265 [....,...Jefferso]
00A1AB3B0 6C43206E 6F746E69 3931046E 32043339 [n Clinton.1993.2]
00A1AB3C0 2C313030 4A0C0300 206E686F 6E6E654B [001,...John Kenn]
00A1AB3D0 04796465 31363931 36393104 03013C33 [edy.1961.1963<..>00A1AB3E0 69774411 20746867 65736945 776F686E [.Dwight Eisenhow] <= 值还在,但是已经标记删除了,所以查不到。
00A1AB3F0 31047265 04333539 31363931 786A0602 [er.1953.1961..jx]
Block header dump: 0x01c0000c
Object id on Block? Y
seg/obj: 0xcd4c csc: 0x00.97868 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00009 ver: 0x01 opc: 0
inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.027.00000146 0x00800081.00df.11 --U- 1 fsc 0x001d.0009786a
0x02 0x0006.00f.00000142 0x008006fb.0126.35 C--- 0 scn 0x0000.00097826
0x01 0x0008.027.00000146 0x00800081.00df.11 --U- 1 fsc 0x001d.0009786a
0x02 0x0006.00f.00000142 0x008006fb.0126.35 C--- 0 scn 0x0000.00097826
data_block_dump,data header at 0xa1a9464
===============
tsiz: 0x1f98
hsiz: 0x18
pbl: 0x0a1a9464
bdba: 0x01c0000c
76543210
flag=--------
ntab=1
nrow=3
frre=-1
fsbo=0x18
fseo=0x1f40
avsp=0x1f28
tosp=0x1f47
0xe:pti[0] nrow=3 ffs=0
0x12:pri[0] ffs=0x1f79
0x14:pri[1] ffs=0x1f5f
0x16:pri[2] ffs=0x1f40
block_row_dump:
tab 0, row 0, @0x1f79
tl: 2 fb: --HDFL-- lb: 0x1 <= --HDFL--已经标记删除,逻辑结构还在但是已经没有数据了。
tab 0, row 1, @0x1f5f
tl: 26 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [12] 4a 6f 68 6e 20 4b 65 6e 6e 65 64 79
col 1: [ 4] 31 39 36 31
col 2: [ 4] 31 39 36 33
tab 0, row 2, @0x1f40
tl: 31 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [17] 4a 65 66 66 65 72 73 6f 6e 20 43 6c 69 6e 74 6f 6e
col 1: [ 4] 31 39 39 33
col 2: [ 4] 32 30 30 31
end_of_block_dump
End dump data blocks tsn: 8 file#: 7 minblk 12 maxblk 12
===============
tsiz: 0x1f98
hsiz: 0x18
pbl: 0x0a1a9464
bdba: 0x01c0000c
76543210
flag=--------
ntab=1
nrow=3
frre=-1
fsbo=0x18
fseo=0x1f40
avsp=0x1f28
tosp=0x1f47
0xe:pti[0] nrow=3 ffs=0
0x12:pri[0] ffs=0x1f79
0x14:pri[1] ffs=0x1f5f
0x16:pri[2] ffs=0x1f40
block_row_dump:
tab 0, row 0, @0x1f79
tl: 2 fb: --HDFL-- lb: 0x1 <= --HDFL--已经标记删除,逻辑结构还在但是已经没有数据了。
tab 0, row 1, @0x1f5f
tl: 26 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [12] 4a 6f 68 6e 20 4b 65 6e 6e 65 64 79
col 1: [ 4] 31 39 36 31
col 2: [ 4] 31 39 36 33
tab 0, row 2, @0x1f40
tl: 31 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [17] 4a 65 66 66 65 72 73 6f 6e 20 43 6c 69 6e 74 6f 6e
col 1: [ 4] 31 39 39 33
col 2: [ 4] 32 30 30 31
end_of_block_dump
End dump data blocks tsn: 8 file#: 7 minblk 12 maxblk 12
BBED> find /c Dwight Eisenhower
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
45697365 6e686f77 65720431 39353304 31393631 0106886e
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8168 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
45697365 6e686f77 65720431 39353304 31393631 0106886e
<32 bytes per line>
BBED> dump /v dba 7,12 offset 8152
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8152 to 8191 Dba:0x01c0000c
-------------------------------------------------------
04313936 333c0103 11447769 67687420 l .1963<...dwight> 45697365 6e686f77 65720431 39353304 l Eisenhower.1953.
31393631 02066a78 l 1961..jx
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8152 to 8191 Dba:0x01c0000c
-------------------------------------------------------
04313936 333c0103 11447769 67687420 l .1963<...dwight> 45697365 6e686f77 65720431 39353304 l Eisenhower.1953.
31393631 02066a78 l 1961..jx
<16 bytes per line>
BBED> p *kdbr[0]
rowdata[57]
-----------
ub1 rowdata[57] @8157 0x3c
rowdata[57]
-----------
ub1 rowdata[57] @8157 0x3c
BBED> dump /v dba 7,12 offset 8157
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8157 to 8191 Dba:0x01c0000c
-------------------------------------------------------
3c010311 44776967 68742045 6973656e l <...dwight eisen> 686f7765 72043139 35330431 39363102 l hower.1953.1961.
066a78 l .jx
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8157 to 8191 Dba:0x01c0000c
-------------------------------------------------------
3c010311 44776967 68742045 6973656e l <...dwight eisen> 686f7765 72043139 35330431 39363102 l hower.1953.1961.
066a78 l .jx
<16 bytes per line>
BBED> modify /x 2c offset 8157
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8157 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
2c010311 44776967 68742045 6973656e 686f7765 72043139 35330431 39363102
066a78
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/oracle/oradata/PROD/datafile/bbed01.dbf (7)
Block: 12 Offsets: 8157 to 8191 Dba:0x01c0000c
------------------------------------------------------------------------
2c010311 44776967 68742045 6973656e 686f7765 72043139 35330431 39363102
066a78
<32 bytes per line>
BBED> sum dba 7,12 apply
Check value for File 7, Block 12:
current = 0x6a39, required = 0x6a39
Check value for File 7, Block 12:
current = 0x6a39, required = 0x6a39
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
--------------------------------------------- -------------------- --------------------
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
System altered.
NAME START_YEAR END_YEAR
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower <= we got it back 1953 1961
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
--------------------------------------------- -------------------- --------------------
Dwight Eisenhower <= we got it back 1953 1961
John Kennedy 1961 1963
Jefferson Clinton 1993 2001
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14614169/viewspace-751160/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14614169/viewspace-751160/