当前位置:Gxlcms > mysql > 使用bbed修改数据

使用bbed修改数据

时间:2021-07-01 10:21:17 帮助过:39人阅读

bbed是一个强大的工具,允许我们绕过oracle直接从数据文件中修改对应的内容 ZBDBA@orcl11gselect * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO---------- -------------------- ------------------ ---------- ------------ ---------- ------

bbed是一个强大的工具,允许我们绕过oracle直接从数据文件中修改对应的内容

ZBDBA@orcl11g>select * from emp;
     EMPNO ENAME                JOB                       MGR HIREDATE            SAL       COMM     DEPTNO
---------- -------------------- ------------------ ---------- ------------ ---------- ---------- ----------
      7499 ALLEN                SALESMAN                 7698 20-FEB-81          1600        300         30
      7521 WARD                 SALESMAN                 7698 22-FEB-81          1250        500         30
      7566 JONES                MANAGER                  7839 02-APR-81          2975                    20
      7654 MARTIN               SALESMAN                 7698 28-SEP-81          1250       1400         30
      7698 BLAKE                MANAGER                  7839 01-MAY-81          2850                    30
      7782 CLARK                MANAGER                  7839 09-JUN-81          2450                    10
      7788 SCOTT                ANALYST                  7566 19-APR-87          3000                    20
      7839 KING                 PRESIDENT                     17-NOV-81          5000                    10
      7844 TURNER               SALESMAN                 7698 08-SEP-81          1500          0         30
      7876 ADAMS                CLERK                    7788 23-MAY-87          1100                    20
      7900 JAMES                CLERK                    7698 03-DEC-81           950                    30
      7902 FORD                 ANALYST                  7566 03-DEC-81          3000                    20
      7934 MILLER               CLERK                    7782 23-JAN-82          1300                    10

13 rows selected.
这里我们查看该表对应的物理块号
ZBDBA@orcl11g>select rowid,dbms_rowid.rowid_object(rowid) robject,
  2  dbms_rowid.rowid_relative_fno(rowid) fno,
  3  dbms_rowid.rowid_block_number(rowid) bno,
  4  dbms_rowid.rowid_row_number(rowid) rno from emp where rownum=1;
ROWID                 ROBJECT        FNO        BNO        RNO
------------------ ---------- ---------- ---------- ----------
AAASKaAAGAAAACDAAA      74394          6        131          
使用bbed进行修改
BBED> set file 6 block 131
        FILE#           6
        BLOCK#          131

BBED> map
File: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)
Block: 131                                   Dba:0x01800083
------------------------------------------------------------
KTB Data Block (Table/Cluster)

struct kcbh, 20 bytes                      @0      

struct ktbbh, 96 bytes                     @20     

struct kdbh, 14 bytes                      @124    

struct kdbt[1], 4 bytes                    @138    

sb2 kdbr[13]                               @142    

ub1 freespace[7491]                        @168    

ub1 rowdata[529]                           @7659   

ub4 tailchk                                @8188   
这里通过字符串形式查找 SCOTT
BBED> find /c SCOTT
File: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)
Block: 131              Offsets: 7902 to 8191           Dba:0x01800083
------------------------------------------------------------------------
53434f54 5407414e 414c5953 5403c24c 430777bb 04130101 0102c21f ff02c115
2c000803 c24e5305 434c4152 4b074d41 4e414745 5203c24f 280777b5 06090101
0103c219 33ff02c1 0b2c0008 03c24d63 05424c41 4b45074d 414e4147 455203c2
4f280777 b5050101 010103c2 1d33ff02 c11f2c00 0803c24d 37064d41 5254494e
0853414c 45534d41 4e03c24d 630777b5 091c0101 0103c20d 3302c20f 02c11f2c
000803c2 4c43054a 4f4e4553 074d414e 41474552 03c24f28 0777b504 02010101
03c21e4c ff02c115 2c000803 c24c1604 57415244 0853414c 45534d41 4e03c24d
630777b5 02160101 0103c20d 3302c206 02c11f2c 000803c2 4b640541 4c4c454e
0853414c 45534d41 4e03c24d 630777b5 02140101 0102c211 02c20402 c11f0206
c656

<32 bytes per line>
dump下来看是不是我们需要的内容:
BBED> d /v offset 7902 count 128
File: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)
Block: 131     Offsets: 7902 to 8029  Dba:0x01800083
-------------------------------------------------------
53434f54 5407414e 414c5953 5403c24c l SCOTT.ANALYST..L
430777bb 04130101 0102c21f ff02c115 l C.w.............
2c000803 c24e5305 434c4152 4b074d41 l ,....NS.CLARK.MA
4e414745 5203c24f 280777b5 06090101 l NAGER..O(.w.....
0103c219 33ff02c1 0b2c0008 03c24d63 l ....3....,....Mc
05424c41 4b45074d 414e4147 455203c2 l .BLAKE.MANAGER..
4f280777 b5050101 010103c2 1d33ff02 l O(.w.........3..
c11f2c00 0803c24d 37064d41 5254494e l ..,....M7.MARTIN

<16 bytes per line>

BBED> d /v offset 7902 count 12
File: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)
Block: 131     Offsets: 7902 to 7913  Dba:0x01800083
-------------------------------------------------------
53434f54 5407414e 414c5953          l SCOTT.ANALYS

<16 bytes per line>

BBED> modify /c 'ZBDBA' offset 7902
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)
Block: 131              Offsets: 7902 to 7913           Dba:0x01800083
------------------------------------------------------------------------
5a424442 4107414e 414c5953

<32 bytes per line>

BBED> d /v offset 7902 count 12
File: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)
Block: 131     Offsets: 7902 to 7913  Dba:0x01800083
-------------------------------------------------------
5a424442 4107414e 414c5953          l ZBDBA.ANALYS

<16 bytes per line>

BBED> sum apply
Check value for File 6, Block 131:
current = 0x60f5, required = 0x60f5

BBED> verify
DBVERIFY - Verification starting
FILE = /opt/oracle/oradata/orcl11g/zbdba01.dbf
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
BBED> 
刷新缓存:
alter system flush buffer_cache;
查看是否修改成功:
ZBDBA@orcl11g>select * from emp;
     EMPNO ENAME                JOB                       MGR HIREDATE            SAL       COMM     DEPTNO
---------- -------------------- ------------------ ---------- ------------ ---------- ---------- ----------
      7499 ALLEN                SALESMAN                 7698 20-FEB-81          1600        300         30
      7521 WARD                 SALESMAN                 7698 22-FEB-81          1250        500         30
      7566 JONES                MANAGER                  7839 02-APR-81          2975                    20
      7654 MARTIN               SALESMAN                 7698 28-SEP-81          1250       1400         30
      7698 BLAKE                MANAGER                  7839 01-MAY-81          2850                    30
      7782 CLARK                MANAGER                  7839 09-JUN-81          2450                    10
      7788 ZBDBA                  KING                 PRESIDENT                     17-NOV-81          5000                    10
      7844 TURNER               SALESMAN                 7698 08-SEP-81          1500          0         30
      7876 ADAMS                CLERK                    7788 23-MAY-87          1100                    20
      7900 JAMES                CLERK                    7698 03-DEC-81           950                    30
      7902 FORD                 ANALYST                  7566 03-DEC-81          3000                    20
      7934 MILLER               CLERK                    7782 23-JAN-82          1300                    10

人气教程排行