Oracle BBED 小小手术刀的小手术---修改数据内容

6320阅读 0评论2015-02-27 jackson198574
分类:Oracle

  



官方简介:

  The name bbed is an acronym for Block Browser and EDitor and it is shipped with thedatabase. It is intended for Oracle internal use only and the company neverpublishes any details about it. It is a very powerful tool but also extremelydangerous since it can change and/or corrupt data blocks of any Oracledatabase.

   If you use this tool, you do so at your own risk. Any modifications made with thistool render the database unsupported by Oracle.
 
   BBED是Oracle的内部工具,不受Oracle技术支持,该工具像一把锋利的手术刀,可以切入数据块内部进行修修改改,因此非常危险,操作需特别谨慎!


实验目的:
 使用BBED修改数据文件内的数据信息。



操作过程:


1.获取数据文件的文件号、文件绝对路径名和大小:
SQL> select file#||' '||name||' '||bytes from v$datafile ;
FILE#||''||NAME||''||BYTES
--------------------------------------------------------------------------------
1 /oracle/app/oradata/ORCL/datafile/o1_mf_system_8xm4839m_.dbf 859832320
2 /oracle/app/oradata/ORCL/datafile/o1_mf_sysaux_8xm483f7_.dbf 555745280
3 /oracle/app/oradata/ORCL/datafile/o1_mf_undotbs1_8xm483gd_.dbf 89128960
4 /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf 70778880
5 /oracle/app/oradata/ORCL/datafile/o1_mf_example_8xm4gzck_.dbf 108134400
6 /oracle/app/oradata/catalog_rman/rmantbs01.dbf 52428800
7 /oracle/app/oradata/ORCL/datafile/gaoqiang.dbf 5242880
8 /oracle/app/oradata/ORCL/datafile/gao.dbf 5242880
9 /oracle/app/oradata/ORCL/datafile/lee.dbf 10485760
10 /oracle/app/oradata/ORCL/datafile/jon.dbf 10485760


10 rows selected.



2.创建文件清单:
[oracle@dbserver oracle]$ vi filelist.txt
加入如下内容:
1 /oracle/app/oradata/ORCL/datafile/o1_mf_system_8xm4839m_.dbf 859832320
2 /oracle/app/oradata/ORCL/datafile/o1_mf_sysaux_8xm483f7_.dbf 555745280
3 /oracle/app/oradata/ORCL/datafile/o1_mf_undotbs1_8xm483gd_.dbf 89128960
4 /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf 70778880
5 /oracle/app/oradata/ORCL/datafile/o1_mf_example_8xm4gzck_.dbf 108134400
6 /oracle/app/oradata/catalog_rman/rmantbs01.dbf 52428800
7 /oracle/app/oradata/ORCL/datafile/gaoqiang.dbf 5242880
8 /oracle/app/oradata/ORCL/datafile/gao.dbf 5242880
9 /oracle/app/oradata/ORCL/datafile/lee.dbf 10485760
10 /oracle/app/oradata/ORCL/datafile/jon.dbf 10485760




[oracle@dbserver oracle]$ cat filelist.txt 
1 /oracle/app/oradata/ORCL/datafile/o1_mf_system_8xm4839m_.dbf 859832320
2 /oracle/app/oradata/ORCL/datafile/o1_mf_sysaux_8xm483f7_.dbf 555745280
3 /oracle/app/oradata/ORCL/datafile/o1_mf_undotbs1_8xm483gd_.dbf 89128960
4 /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf 70778880
5 /oracle/app/oradata/ORCL/datafile/o1_mf_example_8xm4gzck_.dbf 108134400
6 /oracle/app/oradata/catalog_rman/rmantbs01.dbf 52428800
7 /oracle/app/oradata/ORCL/datafile/gaoqiang.dbf 5242880
8 /oracle/app/oradata/ORCL/datafile/gao.dbf 5242880
9 /oracle/app/oradata/ORCL/datafile/lee.dbf 10485760
10 /oracle/app/oradata/ORCL/datafile/jon.dbf 10485760



3.创建bbed参数文件:
[oracle@dbserver oracle]$ cat bbed.par
blocksize=8192
listfile=/oracle/filelist.txt
mode=edit



4.登陆BBED:
[oracle@dbserver oracle]$ bbed parfile=/oracle/bbed.par
Password: 


BBED: Release 2.0.0.0.0 - Limited Production on Tue Jan 27 05:56:31 2015


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


************* !!! For Oracle Internal Use only !!! ***************                   ----谨慎使用,No Zuo No Die~~~












5.查看未修改的表状态:
SQL> select * from summary;


ID INFO
---------- ----------------------------
1 Eric Gao is a Oracle DBA
1 Eric Gao is a PostgreSQL DBA
1 Eric Gao is a AIX SA
1 Eric Gao is a Linux SA


6.查看物理信息:
SQL> select rowid,dbms_rowid.rowid_relative_fno(rowid) rel_fno,dbms_rowid.rowid_block_number(rowid) blockno,dbms_rowid.rowid_row_number(rowid) rowno from summary;


ROWID      REL_FNO BLOCKNO      ROWNO
------------------ ---------- ---------- ----------
AAASmYAAEAAAAKNAAA    4     653  0
AAASmYAAEAAAAKNAAB    4     653  1
AAASmYAAEAAAAKNAAC    4     653  2
AAASmYAAEAAAAKNAAD    4     653  3

dbms_rowid.rowid_relative_fno(rowid)该函数返回输入参数rowid所对应的文件号,文件号是相对于表空间的。
其他的两个函数以此类推分别是:数据块号获取函数和行号获取函数。



7.在bbed中找相关的关键字:
BBED> set dba 4,653 offset 0
DBA             0x0100028d (16777869 4,653)
OFFSET         0



BBED> find /c Oracle
 File: /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf (4)
 Block: 653              Offsets: 8178 to 8191           Dba:0x0100028d
------------------------------------------------------------------------
 4f726163 6c652044 42410106 0385 


 <32 bytes per line>




8.查看该位置的信息:
BBED> dump /v dba 4,653 offset 8178 count 6
 File: /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf (4)
 Block: 653     Offsets: 8178 to 8183  Dba:0x0100028d
-------------------------------------------------------
 4f726163 6c65                       l Oracle


 <16 bytes per line>




9.修改数据块信息:
BBED> modify /c 'ORACLE' dba 4,653 offset 8178
 File: /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf (4)
 Block: 653              Offsets: 8178 to 8183           Dba:0x0100028d
------------------------------------------------------------------------
 4f524143 4c45 


 <32 bytes per line>

10.输出修改后的内容:
BBED> dump /v dba 4,653 offset 8178 count 6
 File: /oracle/app/oradata/ORCL/datafile/o1_mf_users_8xm483jk_.dbf (4)
 Block: 653     Offsets: 8178 to 8183  Dba:0x0100028d
-------------------------------------------------------
 4f524143 4c45                       l ORACLE


 <16 bytes per line>

11.保存:
BBED> sum dba 4,653
Check value for File 4, Block 653:
current = 0x7bcf, required = 0x5bcf



BBED> sum dba 4,653 apply
Check value for File 4, Block 653:
current = 0x5bcf, required = 0x5bcf





12.验证修改成果
SQL> conn eric
SQL> alter system flush buffer_cache;
System altered.


SQL> select * from summary; 
ID INFO
---------- ----------------------------
1 Eric Gao is a ORACLE DBA    -----可以看到该数据已经由原来的Oracle修改成了ORACLE。
1 Eric Gao is a PostgreSQL DBA
1 Eric Gao is a AIX SA
1 Eric Gao is a Linux SA



OK!修改完成!




PS:这是个非常2的测试,完全可以用语句: update summary set info='Eric Gao is a ORACLE DBA' where info='Eric Gao is a ORACLE DBA';  修改过来...

本次实验仅为了提供简单的BBED小小手术刀操作体验。




SQL>  update summary set info='Eric Gao is a Oracle DBA' where info='Eric Gao is a ORACLE DBA';


1 row updated.


SQL> select * from summary;


ID INFO
---------- ----------------------------
1 Eric Gao is a ORACLE DBA
1 Eric Gao is a PostgreSQL DBA
1 Eric Gao is a AIX SA
1 Eric Gao is a Linux SA

上一篇:PostgreSQL数据库在线备份配置
下一篇:PostgreSQL使用PG_RMAN进行在线热备份和恢复操作演示