10g:
[oracle@styrac1 ~]$ cd $ORACLE_HOME/rdbms/lib/
[oracle@styrac1 lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
11g:
拷贝10g的文件
[oracle@styrac2 lib]$ mkdir /tmp/libtmp
[oracle@styrac2 lib]$ mkdir /tmp/msgtmp
[oracle@styrac2 lib]$ cp $ORACLE_HOME/rdbms/lib/ssbbded.o /tmp/libtmp
[oracle@styrac2 lib]$ cp $ORACLE_HOME/rdbms/lib/sbbdpt.o /tmp/libtmp
[oracle@styrac2 lib]$ ls /tmp/libtmp
sbbdpt.o ssbbded.o
[oracle@styrac2 lib]$ cp $ORACLE_HOME/rdbms/mesg/bbed* /tmp/msgtmp
[oracle@styrac2 lib]$ ls /tmp/msgtmp
bbedus.msb bbedus.msg
上传到11g服务器上面
cp libtmp/* $ORACLE_HOME/rdbms/lib/
cp msgtmp/* $ORACLE_HOME/rdbms/mesg/
执行make
[oracle@james-test ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@james-test lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
2. 创建flist文件
sys@FAKE> select file#||' '||name||' '||bytes as flist from v$datafile ; FLIST ---------------------------------------------------------------------- 1 /u01/apps/oracle/oradata/fake/system01.dbf 744488960 2 /u01/apps/oracle/oradata/fake/sysaux01.dbf 703922176 3 /u01/apps/oracle/oradata/fake/undotbs01.dbf 325058560 4 /u01/apps/oracle/oradata/fake/users01.dbf 16777216 5 /u01/apps/oracle/oradata/fake/example01.dbf 104857600
[oracle@oel bbed]$ cat flist.txt
1 /u01/apps/oracle/oradata/fake/system01.dbf 744488960
2 /u01/apps/oracle/oradata/fake/sysaux01.dbf 703922176
3 /u01/apps/oracle/oradata/fake/undotbs01.dbf 325058560
4 /u01/apps/oracle/oradata/fake/users01.dbf 16777216
5 /u01/apps/oracle/oradata/fake/example01.dbf 104857600
3. 创建parfile
sys@FAKE> show parameter db_block_size NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_block_size integer 8192
[oracle@oel bbed]$ cat dex.par
blocksize=8192
listfile=/home/oracle/bbed/flist.txt
mode=broswer
password=blockedit
方便一下放进环境变量里面
alias bbed='rlwrap bbed parfile=/home/oracle/bbed/dex.par'
4. 下面我们来修改数据
本例子基于11g
首先补充一下基本知识,假设块大小为
8kb=8192byte
1byte=8bit
dump文件使用16进制编码
所以可以使用2个16进制编码代表1byte
因此一个块中总共有8192*2=16384个0到F的代码构成,每2位代表一个字节。
sys@FAKE> select t.*, 2 dbms_rowid.rowid_relative_fno(t.rowid) as "FNO#", 3 dbms_rowid.rowid_block_number(t.rowid) as "BLK#", 4 dbms_rowid.rowid_row_number(t.rowid) as "ROW#" 5 from scott.emp t 6 where t.empno = 7839; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO FNO# BLK# ROW# ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ---------- ---------- ---------- 7839 KING PRESIDENT 17-NOV-81 5000 10 4 29 8
就来修改一下emp 表中 的 7839 这条记录把 修改sal为4000
先来看一下5000的十六制码是多少
sys@FAKE> select dump(5000,1016) from dual; DUMP(5000,1016) ------------------ Typ=2 Len=2: c2,33
使用十六进制码查找一下
BBED> find /x c233
File: /u01/apps/oracle/oradata/fake/users01.dbf (4)
Block: 29 Offsets: 7850 to 8191 Dba:0x0100001d
------------------------------------------------------------------------
c233ff02 c10b2c01 0803c24e 59055343 4f545407 414e414c 59535403 c24c4307
77bb0413 01010102 c21fff02 c1152c01 0803c24e 5305434c 41524b07 4d414e41
47455203 c24f2807 77b50609 01010103 c21933ff 02c10b2c 010803c2 4d630542
4c414b45 074d414e 41474552 03c24f28 0777b505 01010101 03c21d33 ff02c11f
2c010803 c24d3706 4d415254 494e0853 414c4553 4d414e03 c24d6307 77b5091c
01010103 c20d3302 c20f02c1 1f2c0108 03c24c43 054a4f4e 4553074d 414e4147
455203c2 4f280777 b5040201 010103c2 1e4cff02 c1152c01 0803c24c 16045741
52440853 414c4553 4d414e03 c24d6307 77b50216 01010103 c20d3302 c20602c1
1f2c0108 03c24b64 05414c4c 454e0853 414c4553 4d414e03 c24d6307 77b50214
01010102 c21102c2 0402c11f 2c010803 c24a4605 534d4954 4805434c 45524b03
c2500307 77b40c11 01010102 c209ff02 c1151006 eece
<32 bytes per line>
offset=7850
查看一下4000的十六进制码
sys@FAKE> select dump(4000.00,1016) from dual; DUMP(4000.00,1016) ------------------ Typ=2 Len=2: c2,29 sys@FAKE> select dump(4000.00,1016) from dual; DUMP(4000.00,1016) ------------------ Typ=2 Len=2: c2,29
BBED> set offset 7850
OFFSET 7850
BBED> m /x c229
BBED-00215: editing not allowed in BROWSE mode
BBED> set mode edit
MODE Edit
BBED> m /x c229
File: /u01/apps/oracle/oradata/fake/users01.dbf (4)
Block: 29 Offsets: 7850 to 7977 Dba:0x0100001d
-----------------------------------------------------------------------
c229ff02 c10b2c01 0803c24e 59055343 4f545407 414e414c 59535403 c24c4307
77bb0413 01010102 c21fff02 c1152c01 0803c24e 5305434c 41524b07 4d414e41
47455203 c24f2807 77b50609 01010103 c21933ff 02c10b2c 010803c2 4d630542
4c414b45 074d414e 41474552 03c24f28 0777b505 01010101 03c21d33 ff02c11f
<32 bytes per line>
生效
BBED> sum
Check value for File 4, Block 29:
current = 0xc587, required = 0xdf87
BBED> sum apply
Check value for File 4, Block 29:
current = 0xdf87, required = 0xdf87
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/apps/oracle/oradata/fake/users01.dbf
BLOCK = 29
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
查询没有变?
sys@FAKE> alter system flush buffer_cache; System altered.
再次查询
sys@FAKE> select t.*, 2 dbms_rowid.rowid_relative_fno(t.rowid) as "FNO#", 3 dbms_rowid.rowid_block_number(t.rowid) as "BLK#", 4 dbms_rowid.rowid_row_number(t.rowid) as "ROW#" 5 from scott.emp t 6 where t.empno = 7839; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO FNO# BLK# ROW# ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ---------- ---------- ---------- 7839 KING PRESIDENT 17-NOV-81 4000 10 4 29 8
注意:这里修改的字节数必须和原来相同。
比如5000十六进制为c233
你不能直接修改为c21f33,这样会覆盖已有数据毁坏,出现类似下面的情况
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO FNO# BLK# ROW# ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ---------- ---------- ---------- 7839 KING PRESIDENT 17-NOV-81 3000 -k.91E+120 -3.619E-27 4 29 8
补充下其他的知识:
BBED> set dba 4,531
DBA 0x01000213 (16777747 4,531)
BBED> p *kdbr[0]
rowdata[2962]
-------------
ub1 rowdata[2962] @8173 0x3c
BBED> set offset 8173
OFFSET 8173
BBED> dump /v
File: /u01/apps/oracle/oradata/david/users01.dbf (4)
Block: 531 Offsets: 8173 to 8191 Dba:0x01000213
-------------------------------------------------------
3c020302 c1020353 59530444 55414c01 l <...Á..SYS.DUAL.
06fbd4 l .ûÔ
<16 bytes per line>
_sys@DAVID> select dump(1,1016) from dual ;
DUMP(1,1016)
-----------------
Typ=2 Len=2: c1,2
_sys@DAVID> select dump('SYS',1016) from dual ;
DUMP('SYS',1016)
--------------------------------------------
Typ=96 Len=3 CharacterSet=ZHS16GBK: 53,59,53
每一行的组成:
1个字节的flag
1个字节的lb(itl slot)
1个字节的column count
如例中
3c=flag=00111100=--HDFL--=header+delete+first+last
02=lb itl slot 0x02
03=column count
列值信息包括:
列的长度,列的value
例如02c102
表示占用2个byte
c102 表示的是具体的值
那么本例中
其他:
null值,如果后面还有列,那么会记为ff
null值,如果是行中的最后一列,那么什么都不会记录。
直接记录下一行的数据
今天就先到这吧。