bbed可以直接查看或修改数据文件,听起来很强大,下面体验一下,安装方法网上一搜一大把,我的环境是centos+10G的 bbed参考文档:http://pan.baidu.com/s/1hqCC6pu --测试之前,已经创建了ms1用户和表空间mssm create tablespace mssm datafile /u01/oracle/
bbed可以直接查看或修改数据文件,听起来很强大,下面体验一下,安装方法网上一搜一大把,我的环境是centos+10G的
bbed参考文档:http://pan.baidu.com/s/1hqCC6pu
--测试之前,已经创建了ms1用户和表空间mssm
create tablespace mssm
datafile ''/u01/oracle/oradata/gname/mssm.dbf
size 50M
extent management local
segment space management manual;
create user ms1 identified by ms1 default tablespace mssm;
[oracle@111 sql]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jul 4 15:32:23 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> conn ms1/ms1
Connected.
SQL> insert into t values(1,'a');
1 row created.
SQL> insert into t values(2,'b');
1 row created.
SQL> insert into t values(999,'seven');
1 row created.
SQL> commit;
Commit complete.
SQL> get getrowidinfo
1 select
2 t.*,
3 --rowid,
4 dbms_rowid.rowid_type(rowid) rowid_type,
5 dbms_rowid.rowid_relative_fno(rowid) file_no,
6 dbms_rowid.rowid_block_number(rowid) block_no,
7 dbms_rowid.rowid_row_number(rowid) row_no,
8 ora_rowscn,
9 dbms_rowid.rowid_object(rowid) object_no
10* from &owner..&table t;
SQL> @getrowidinfo
Enter value for owner: ms1
Enter value for table: t
old 8: from &owner..&table
new 8: from ms1.t
RN ROWID_TYPE FILE_NO BLOCK_NO ROW_NO ORA_ROWSCN OBJECT_NO
---------- ---------- ---------- ---------- ---------- ---------- ----------
1 1 7 10 0 506534 52503
2 1 7 10 1 506534 52503
3 1 7 10 2 506534 52503
SQL> select DEFAULT_TABLESPACE from dba_users where username=user;
DEFAULT_TABLESPACE
------------------------------------------------------------
MSSM
SQL> @getfile
FILE_ID FILE_NAME TABLESPACE_NAME M
---------- -------------------------------------------------- -------------------- ----------
5 /u01/oracle/oradata/gname/example01.dbf EXAMPLE 100
7 /u01/oracle/oradata/gname/mssm.dbf MSSM 50
3 /u01/oracle/oradata/gname/sysaux01.dbf SYSAUX 240
1 /u01/oracle/oradata/gname/system01.dbf SYSTEM 480
6 /u01/oracle/oradata/gname/tab.dbf TAB 100
2 /u01/oracle/oradata/gname/undotbs01.dbf UNDOTBS1 30
4 /u01/oracle/oradata/gname/users01.dbf USERS 5
[oracle@111 sql]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jul 4 16:42:51 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@111 sql]$ cp /u01/oracle/oradata/gname/mssm.dbf /u01/oracle/oradata/gname/mssm.dbf_bak20140704
[oracle@111 sql]$ ll /u01/oracle/oradata/gname/mssm*
-rw-r-----. 1 oracle oinstall 52436992 Jul 4 16:44 /u01/oracle/oradata/gname/mssm.dbf
-rw-r-----. 1 oracle oinstall 52436992 Jul 4 16:45 /u01/oracle/oradata/gname/mssm.dbf_bak20140704
SQL> select file#||' '||name||' '||bytes from v$datafile ;
FILE#||''||NAME||''||BYTES
--------------------------------------------------------------------------------
1 /u01/oracle/oradata/gname/system01.dbf 503316480
2 /u01/oracle/oradata/gname/undotbs01.dbf 31457280
3 /u01/oracle/oradata/gname/sysaux01.dbf 251658240
4 /u01/oracle/oradata/gname/users01.dbf 5242880
5 /u01/oracle/oradata/gname/example01.dbf 104857600
6 /u01/oracle/oradata/gname/tab.dbf 104857600
7 /u01/oracle/oradata/gname/mssm.dbf 52428800
7 rows selected.
[oracle@111 /]$ cd /u01/bbed/
[oracle@111 bbed]$ vi filelist.txt
1 /u01/oracle/oradata/gname/system01.dbf 503316480
2 /u01/oracle/oradata/gname/undotbs01.dbf 31457280
3 /u01/oracle/oradata/gname/sysaux01.dbf 251658240
4 /u01/oracle/oradata/gname/users01.dbf 5242880
5 /u01/oracle/oradata/gname/example01.dbf 104857600
6 /u01/oracle/oradata/gname/tab.dbf 104857600
7 /u01/oracle/oradata/gname/mssm.dbf 52428800
999 /u01/oracle/oradata/gname/mssm.dbf_bak20140704 52428800
[oracle@111 bbed]$ vi bbed.par
blocksize=8192
listfile=/u01/bbed/filelist.txt
mode=edit
[oracle@111 bbed]$ bbed parfile=/u01/bbed/bbed.par
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Fri Jul 4 17:05:34 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> show
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /u01/oracle/oradata/gname/system01.dbf
BIFILE bifile.bbd
LISTFILE /u01/bbed/filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/oracle/oradata/gname/system01.dbf 61440
2 /u01/oracle/oradata/gname/undotbs01.dbf 3840
3 /u01/oracle/oradata/gname/sysaux01.dbf 30720
4 /u01/oracle/oradata/gname/users01.dbf 640
5 /u01/oracle/oradata/gname/example01.dbf 12800
6 /u01/oracle/oradata/gname/tab.dbf 12800
7 /u01/oracle/oradata/gname/mssm.dbf 6400
999 /u01/oracle/oradata/gname/mssm.dbf 6400
BBED> set file 7 block 10
FILE# 7
BLOCK# 10
BBED> show
FILE# 7
BLOCK# 10
OFFSET 0
DBA 0x01c0000a (29360138 7,10)
FILENAME /u01/oracle/oradata/gname/mssm.dbf
BIFILE bifile.bbd
LISTFILE /u01/bbed/filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED> dump file 7 block 10
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 0 to 511 Dba:0x01c0000a
------------------------------------------------------------------------
06a20000 0a00c001 a6ba0700 00000706 75f20000 01000000 17cd0000 96ba0700
00000000 02000300 00000000 02002500 0d010000 e8008000 3b010300 03200000
a6ba0700 00000000 00000000 00000000 00000000 00000000 00000000 00010300
ffff1800 831f691f 691f0000 0300981f 901f831f 00001300 09001c00 25004100
4b00891f 721f5b1f 441f2d1f 161fff1e e81ed11e ba1e2b1e 9c1d121d 871cfd1b
721be71a 5c1ad119 6e190919 ab184d18 7601ef17 91173317 d516ba16 9f168416
69164e16 33161816 fd15e215 c715ac15 91157615 5b154015 25150a15 ef14d414
b9149e14 83146814 4d143214 1714fc13 e113c613 ab139013 75135a13 3f132413
0913ee12 b1126c12 2e12f611 b8117411 3611f210 b7107610 44101010 d60f9a0f
5b0f1b0f e50eb10e 7f0e400e 020ecd0d 9b0d5e0d 1f0dea0c b80c830c 510c140c
d50ba00b 6e0b390b 070bca0a 8b0a500a 150add09 a5097009 3e090109 c2088708
4c081408 dc07a707 75073807 fa06bf06 86064a06 0d06d805 a6056905 2b05f104
c1047d04 3904fb03 ba037703 38030303 d1029402 58021e02 d3010000 006c0214
0102c108 02c10802 c11a0180 05525449 4d4502c1 0202c11a 0180ffff 0180ffff
02c10801 8003c209 4a02c102 01806c00 14096c00 210503c2 5c20ff01 80018001
80018002 c1060180 01800180 ff02c102 03c21533 03c22964 018002c1 0203c202
<32 bytes per line>
BBED> dump file 7 block 10 count 8200
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 0 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
06a20000 0a00c001 a6ba0700 00000706 75f20000 01000000 17cd0000 96ba0700
00000000 02000300 00000000 02002500 0d010000 e8008000 3b010300 03200000
a6ba0700 00000000 00000000 00000000 00000000 00000000 00000000 00010300
ffff1800 831f691f 691f0000 0300981f 901f831f 00001300 09001c00 25004100
4b00891f 721f5b1f 441f2d1f 161fff1e e81ed11e ba1e2b1e 9c1d121d 871cfd1b
...
0f000040 6a8c0006 00406a8c 000603c2 5c22ac00 010f000f 0000406a 8c000500
406a8c00 0503c25c 1eac0001 0d000d00 00406a8c 00040040 6a8c0004 03c25c1c
ac00010d 000d0000 406a8c00 0300406a 8c000303 c25c18ac 00010800 08000040
6a8c0002 00406a8c 000203c2 5c16ac00 010c000c 0000406a 8c000100 406a8c2c
010203c2 0a640573 6576656e 2c010202 c1030162 2c010202 c1020161 0706a6ba
<32 bytes per line>
SQL> select dump(id,16) from t;
DUMP(ID,16)
--------------------------------------------------------------------------------
Typ=2 Len=2: c1,2
Typ=2 Len=2: c1,3
Typ=2 Len=3: c2,a,64
SQL> select dump(name,16) from t;
DUMP(NAME,16)
--------------------------------------------------------------------------------
Typ=1 Len=1: 61
Typ=1 Len=1: 62
Typ=1 Len=5: 73,65,76,65,6e
SQL> @getrowidinfo
Enter value for owner: ms1
Enter value for table: t
ID NAME ROWID_TYPE FILE_NO BLOCK_NO ROW_NO ORA_ROWSCN OBJECT_NO
---------- -------------------- ---------- ---------- ---------- ---------- ---------- ----------
1 a 1 7 10 0 506534 52503
2 b 1 7 10 1 506534 52503
999 seven 1 7 10 2 506534 52503
BBED> set file 7 block 10 offset 0
FILE# 7
BLOCK# 10
OFFSET 0
BBED> find /c a top
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
610706a6 ba
<32 bytes per line>
BBED> d /v dba 7,10 offset 8187
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
-------------------------------------------------------
610706a6 ba l a....
<16 bytes per line>
BBED> set file 7 block 10 offset 2
FILE# 7
BLOCK# 10
OFFSET 2
BBED> find /c s top
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8167 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
73657665 6e2c0102 02c10301 622c0102 02c10201 610706a6 ba
<32 bytes per line>
BBED> d /v dba 7,10 offset 8167
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8167 to 8191 Dba:0x01c0000a
-------------------------------------------------------
73657665 6e2c0102 02c10301 622c0102 l seven,......b,..
02c10201 610706a6 ba l ....a....
<16 bytes per line>
SQL> update t set name='sven' where id=999;
1 row updated.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
SQL>
SQL> @getrowidinfo
Enter value for owner: ms1
Enter value for table: t
ID NAME ROWID_TYPE FILE_NO BLOCK_NO ROW_NO ORA_ROWSCN OBJECT_NO
---------- -------------------- ---------- ---------- ---------- ---------- ---------- ----------
1 a 1 7 10 0 513384 52503
2 b 1 7 10 1 513384 52503
999 sven 1 7 10 2 513384 52503
BBED> set file 7 block 10 offset 2
FILE# 7
BLOCK# 10
OFFSET 2
BBED> find /c s top --查找字符串s
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8155 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
7376656e 2c000203 c20a6405 73657665 6e2c0002 02c10301 622c0002 02c10201
61020668 d5
<32 bytes per line>
BBED> d /v dba 7,10 offset 8155
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8155 to 8191 Dba:0x01c0000a
-------------------------------------------------------
7376656e 2c000203 c20a6405 73657665 l sven,.....d.seve --可以看出update之前的数据seven还在数据块里面的,新的值sevn插入在上面
6e2c0002 02c10301 622c0002 02c10201 l n,......b,......
61020668 d5 l a..h.
<16 bytes per line>
更改数据
SQL> @getrowidinfo
Enter value for owner: ms1
Enter value for table: t
ID NAME ROWID_TYPE FILE_NO BLOCK_NO ROW_NO ORA_ROWSCN OBJECT_NO
---------- -------------------- ---------- ---------- ---------- ---------- ---------- ----------
1 a 1 7 10 0 513384 52503
2 b 1 7 10 1 513384 52503
999 sven 1 7 10 2 513384 52503
--我想把name字段的a改成c
SQL> select dump('a',16) from dual;
DUMP('A',16)
--------------------------------
Typ=96 Len=1: 61
SQL> select dump('c',16) from dual;
DUMP('C',16)
--------------------------------
Typ=96 Len=1: 63
BBED> f /x 61 curr --先找到61的位置 offset=8187
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
61020668 d5
<32 bytes per line>
BBED> d /v offset 8187 --dump内容出来 offset=8187,可以看到字符a
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
-------------------------------------------------------
61020668 d5 l a..h.
<16 bytes per line>
BBED> help m --m:modify 修改数据的命令
MODIFY[/x|d|u|o|c] numeric/character string
[ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
BBED> m /x 63 dba 7,10 offset 8187 --修改为63
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
63020668 d5 --这里由61020668--> 63020668
<32 bytes per line>
BBED> verify --检查一下块的完整性
DBVERIFY - Verification starting
FILE = /u01/oracle/oradata/gname/mssm.dbf
BLOCK = 10
Block 10 is corrupt
Corrupt block relative dba: 0x01c0000a (file 0, block 10)
Bad check value found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x01c0000a
last change scn: 0x0000.0007d568 seq: 0x2 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xd5680602
check value in block header: 0x5a29
computed block checksum: 0x200
DBVERIFY - Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
BBED> d /v offset 8187
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
-------------------------------------------------------
63020668 d5 l c..h. --这里由a..h.变成c..h.
<16 bytes per line>
BBED> undo --undo,回滚上一步
BBED> modify /x 61 filename '/u01/oracle/oradata/gname/mssm.dbf' block 10. offset 8187.
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
61020668 d5 --这里由63020668--> 61020668
<32 bytes per line>
--验证undo只能回滚上一步,revert可以回滚全部
BBED> m /x 62
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
62020668 d5
<32 bytes per line>
BBED> m /x 63
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
63020668 d5
<32 bytes per line>
BBED> m /x 64
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
64020668 d5
<32 bytes per line>
BBED> d /v
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
-------------------------------------------------------
64020668 d5 l d..h.
<16 bytes per line>
BBED> undo --回到上一步
BBED> modify /x 63 filename '/u01/oracle/oradata/gname/mssm.dbf' block 10. offset 8187.
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
63020668 d5
<32 bytes per line>
BBED> revert --回到最初
All changes made in this session will be rolled back. Proceed? (Y/N) y
Reverted file '/u01/oracle/oradata/gname/mssm.dbf', block 10
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
BBED> d /v
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
-------------------------------------------------------
61020668 d5 l a..h.
<16 bytes per line>
真的要改数据了
BBED> show
FILE# 7
BLOCK# 10
OFFSET 8187
DBA 0x01c0000a (29360138 7,10)
FILENAME /u01/oracle/oradata/gname/mssm.dbf
BIFILE bifile.bbd
LISTFILE /u01/bbed/filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 300
LOGFILE log.bbd
SPOOL No
BBED> m /x 63
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
63020668 d5
<32 bytes per line>
BBED> sum
Check value for File 7, Block 10:
current = 0x5a29, required = 0x5829
SQL> select * from t;
ID NAME
---------- --------------------
1 a
2 b
999 sven
BBED> sum apply --真正应用之前的修改,类似oracle的commit
Check value for File 7, Block 10:
current = 0x5829, required = 0x5829
SQL> /
ID NAME
---------- --------------------
1 a
2 b
999 sven
SQL> conn / as sysdba
Connected.
SQL> startup force
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 79693392 bytes
Database Buffers 201326592 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> conn ms1/ms1
Connected.
SQL> select * from t;
ID NAME
---------- --------------------
1 c
2 b
999 sven
copy块复制命令
BBED> set file 7 block 10 offset 8187
FILE# 7
BLOCK# 10
OFFSET 8187
BBED> d /v dba 999,10 offset 8187
File: /u01/oracle/oradata/gname/mssm.dbf_bak20140704 (999) --备份文件中是a
Block: 10 Offsets: 8187 to 8191 Dba:0xf9c0000a
-------------------------------------------------------
610706a6 ba l a....
<16 bytes per line>
BBED> d /v dba 7,10 offset 8187
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a --当前数据文件中是e
-------------------------------------------------------
65020668 d5 l e..h.
<16 bytes per line>
BBED> copy dba 999,10 to dba 7,10 --copy覆盖
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/oracle/oradata/gname/mssm.dbf (7)
Block: 10 Offsets: 8187 to 8191 Dba:0x01c0000a
------------------------------------------------------------------------
610706a6 ba
<32 bytes per line>
SQL> conn ms1/ms1
Connected.
SQL> select * from t;
ID NAME
---------- --------------------
1 e
2 b
999 sven
SQL> conn / as sysdba
Connected.
SQL> startup force
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 79693392 bytes
Database Buffers 201326592 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> select * from ms1.t; --重启才生效
ID NAME
---------- --------------------
1 a
2 b
999 seven