http://space.itpub.net/9664900/viewspace-740730
虽然bbed可以在db open状态来进行修改,但是建议在做任何修改操作之前先关闭数据库。这样避免checkpoint进程重写bbed对block的修改。也避免oracle在bbed修改完成之前读block或者申明block为corrupt。
1、进入bbed
[oracle@zll:/soft]$bbed parfile=bbed.par
Password: blockedit
BBED: Release2.0.0.0.0 - Limited Production on Sat Aug 11 08:54:49 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> info
File# Name Size(blks)
----- ---- ----------
6 /oracle/app/oracle/oradata/zlldb/zll01.256.790241825 6400
2、查看要修改的内容
SQL> select * from test01;
ID NAME
---------- ------------------------------------------------------------
1 zhou
2 zll
3 zhoulinling
注意:bbed的修改仅仅是对原有位置内容的一个替换。
对应block的信息如下:
SQL> select
2 rowid,
3 dbms_rowid.rowid_relative_fno(rowid)rel_fno,
4 dbms_rowid.rowid_block_number(rowid)blockno,
5 dbms_rowid.rowid_row_number(rowid) rowno
6 from test01;
ROWID REL_FNO BLOCKNO ROWNO
------------------ ---------- ---------- ----------
AAATwpAAGAAAACDAAA 6 131 0
AAATwpAAGAAAACDAAB 6 131 1
AAATwpAAGAAAACDAAC 6 131 2
3、查找关键字zhoulinling,确定其在block中的偏移量offset。
BBED>set dba 6,131 offset 0
DBA 0x01800083 (25165955 6,131)
OFFSET 0
BBED>find /c zhoulinling
File: /oracle/app/oracle/oradata/zlldb/zll01.256.790241825 (6)
Block: 131 Offsets: 8156 to 8191 Dba:0x01800083
------------------------------------------------------------------------
7a686f756c696e6c696e672c000202c103037a6c6c2c000202c102047a686f75
0206ad64
<32 bytes per line>
dump查看具体内容
BBED>dump /v
File: /oracle/app/oracle/oradata/zlldb/zll01.256.790241825 (6)
Block: 131 Offsets: 8156 to 8191 Dba:0x01800083
-------------------------------------------------------
7a686f756c696e6c696e672c000202c1 lzhoulinling,....
03037a6c6c2c000202c102047a686f75 l..zll,......zhou
0206ad64 l...d
<16 bytes per line>
注意这里面的Offsets:8156 to 8191,它指的是这一行的一个地址。其中:
z的offset是8156
h的offset是8157
o的offset是8158
u的offset是8159
l的offset是8160
i的offset是8161
n的offset是8162
l的offset是8163
i的offset是8164
n的offset是8165
g的offset是8166
//空格也算offset。
4、修改block,将zhoulinling换成zhouling
BBED>modify /c 'zhouling ' dba 6,131 offset 8156
File: /oracle/app/oracle/oradata/zlldb/zll01.256.790241825 (6)
Block: 131 Offsets: 8156 to 8191 Dba:0x01800083
------------------------------------------------------------------------
7a686f756c696e672020202c000202c103037a6c6c2c000202c102047a686f75
0206ad64
<32 bytes per line>
BBED>dump /v
File: /oracle/app/oracle/oradata/zlldb/zll01.256.790241825 (6)
Block: 131 Offsets: 8156 to 8191 Dba:0x01800083
-------------------------------------------------------
7a686f756c696e672020202c000202c1 lzhouling ,....
03037a6c6c2c000202c102047a686f75 l..zll,......zhou
0206ad64 l...d
<16 bytes per line>
//注意这里zhouling我用单引号括起来,并且最后还有3个空格,这样就是7个bytes,不用单引号括起来,无法表示空格,验证一下
5、应用变更生效
BBED>sum dba 6,131
Check value for File 6, Block 131:
current = 0xf909, required = 0xbc07
此时current checksum是0xf909,requiredchecksum是0xbc07
BBED>sum dba 6,131 apply
Check value for File 6, Block 131:
current = 0xbc07, required = 0xbc07
加上apply参数,使checksum一致。即之前的修改生效。
BBED>verify
DBVERIFY - Verification starting
FILE = /oracle/app/oracle/oradata/zlldb/zll01.256.790241825
BLOCK = 131
DBVERIFY - Verification complete
Total 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 Corrupt : 0
Total Blocks Influx : 0
Message 531 not found; product=RDBMS; facility=BBED
我们来检查数据内容的变化:
SQL>alter system flush buffer_cache;
System altered.
SQL> select * from test01;
ID NAME
---------- ------------------------------------------------------------
1 zhou
2 zll
3 zhouling
OK,已经修改成功