ITPub博客

首页 > 数据库 > Oracle > BBED学习之一

BBED学习之一

原创 Oracle 作者:parknkjun 时间:2014-03-24 10:10:22 0 删除 编辑
一、BBED安装
[oracle@10g ~]$ cd /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/
[oracle@10g lib]$ make -f ins_rdbms.mk /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/bbed
密码:blockedit
二、进入BBED
[oracle@10g lib]$ ./bbed
Password: blockedit
BBED: Release 2.0.0.0.0 - Limited Production on Sun Mar 23 14:10:03 2014
Copyright (c) 1982, 2005, Oracle.  All rights reserved.


************* !!! For Oracle Internal Use only !!! ***************
BBED> 
三、查看帮助
BBED> help all;
SET DBA [ dba | file#, block# ]
SET FILENAME 'filename'
SET FILE file#
SET BLOCK [+/-]block#
SET OFFSET [ [+/-]byte offset | symbol | *symbol ]
SET BLOCKSIZE bytes
SET LIST[FILE] 'filename'
SET WIDTH character_count
SET COUNT bytes_to_display
SET IBASE [ HEX | OCT | DEC ]
SET OBASE [ HEX | OCT | DEC ]
SET MODE  [ BROWSE | EDIT ]
SET SPOOL [ Y | N ]
SHOW [ | ALL ]
INFO
MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]
DUMP[/v] [ DBA | FILENAME | FILE | BLOCK | OFFSET | COUNT ]
PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
:
N - a number which specifies a repeat count.
u - a letter which specifies a unit size:
  b - b1, ub1 (byte)
  h - b2, ub2 (half-word)
  w - b4, ub4(word)
  r - Oracle table/index row
f - a letter which specifies a display format:
  x - hexadecimal
  d - decimal
  u - unsigned decimal
  o - octal
  c - character (native)
  n - Oracle number
  t - Oracle date
  i - Oracle rowid
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
MODIFY[/x|d|u|o|c] numeric/character string
      [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
ASSIGN[/x|d|u|o] =
: [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
: [ value | ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]
POP [ALL]
REVERT [ DBA | FILE | FILENAME | BLOCK ]
UNDO
HELP [ | ALL ]
VERIFY [ DBA | FILE | FILENAME | BLOCK ]
CORRUPT [ DBA | FILE | FILENAME | BLOCK ]
四、测试
1、创建表空间test
SYS@ORCL>create tablespace test datafile
    '/u01/app/oracle/oradata/test01.dbf' size 10m;
Tablespace created.
SYS@ORCL>select file_id,file_name from dba_data_files;
   FILE_ID FILE_NAME
---------- --------------------------------------------------
         4 /u01/app/oracle/oradata/ORCL/users01.dbf
         3 /u01/app/oracle/oradata/ORCL/sysaux01.dbf
         2 /u01/app/oracle/oradata/ORCL/undotbs01.dbf
         1 /u01/app/oracle/oradata/ORCL/system01.dbf
         5 /u01/app/oracle/oradata/test01.dbf
2、创建用户jzh
SYS@ORCL>create user jzh identified by jzh default tablespace TEST;
User created.
SYS@ORCL>grant dba to jzh;
Grant succeeded.
3、创建测试表、插入数据
JZH@ORCL>create table t (id int,name varchar2(30)) tablespace test;
Table created.
JZH@ORCL>insert into t values(1,'jzha');
1 row created.
JZH@ORCL>insert into t values(2,'jzhb');
1 row created.
JZH@ORCL>insert into t values(3,'jzhc');
1 row created.
JZH@ORCL>commit;
Commit complete.
JZH@ORCL>select dbms_rowid.ROWID_RELATIVE_FNO(rowid),dbms_rowid.ROWID_BLOCK_NUMBER(rowid),id,name from t;
DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)         ID NAME
------------------------------------ ------------------------------------ ---------- ------------------------------
                                   5                                   14          1 jzha
                                   5                                   14          2 jzhb
                                   5                                   14          3 jzhc
4、设置文件
BBED> set filename '/u01/app/oracle/oradata/test01.dbf'
        FILENAME        /u01/app/oracle/oradata/test01.dbf
5、设置文件编号
BBED> set file 5
        FILE#           5
BBED> set block 14
        BLOCK#          14
6、设置块号
BBED> show all
        FILE#           5
        BLOCK#          14
        OFFSET          0
        DBA             0x0140000e (20971534 5,14)
        FILENAME        /u01/app/oracle/oradata/test01.dbf
        BIFILE          bifile.bbd
        LISTFILE        /home/oracle/bbed.lst
        BLOCKSIZE       8192
        MODE            Browse
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No
7、设置编辑模式
BBED> set MODE edit
        MODE            Edit
8、设置块大小
BBED> set count 8192
        COUNT           8192
9、dump块结构
BBED> dump
 File: /u01/app/oracle/oradata/test01.dbf (5)
 Block: 14               Offsets:    0 to 8191           Dba:0x0140000e
------------------------------------------------------------------------
 06a20000 0e004001 3a780800 00000506 5ebd0000 01000000 9cc80000 e0770800 
 00000000 02003200 09004001 04001a00 27010000 0c078000 ab002000 03200000 
 3a780800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00010300 ffff1800 771f5f1f 5f1f0000 03008d1f 821f771f 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

JZH@ORCL>alter system dump datafile 5 block 14;
[oracle@10g udump]$ more orcl_ora_17005.trc
/u01/app/oracle/admin/ORCL/udump/orcl_ora_17005.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1
System name:    Linux
Node name:      10g
Release:        2.6.32-200.13.1.el5uek
Version:        #1 SMP Wed Jul 27 21:02:33 EDT 2011
Machine:        x86_64
Instance name: ORCL
Redo thread mounted by this instance: 1
Oracle process number: 17
Unix process pid: 17005, image: oracle@10g (TNS V1-V3)

*** 2014-03-23 14:50:28.074
*** ACTION NAME:() 2014-03-23 14:50:28.074
*** MODULE NAME:(SQL*Plus) 2014-03-23 14:50:28.074
*** SERVICE NAME:(SYS$USERS) 2014-03-23 14:50:28.074
*** SESSION ID:(149.21) 2014-03-23 14:50:28.074
Start dump data blocks tsn: 6 file#: 5 minblk 14 maxblk 14
buffer tsn: 6 rdba: 0x0140000e (5/14)
scn: 0x0000.0008783a seq: 0x05 flg: 0x06 tail: 0x783a0605
frmt: 0x02 chkval: 0xbd5e type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x00000000079F9200 to 0x00000000079FB200
0079F9200 0000A206 0140000E 0008783A 06050000  [......@.:x......]
0079F9210 0000BD5E 00000001 0000C89C 000877E0  [^............w..]
0079F9220 00000000 00320002 01400009 001A0004  [......2...@.....]
0079F9230 00000127 0080070C 002000AB 00002003  ['......... .. ..]
0079F9240 0008783A 00000000 00000000 00000000  [:x..............]
0079F9250 00000000 00000000 00000000 00000000  [................]
0079F9260 00000000 00030100 0018FFFF 1F5F1F77  [............w._.]
0079F9270 00001F5F 1F8D0003 1F771F82 00000000  [_.........w.....]
0079F9280 00000000 00000000 00000000 00000000  [................]
        Repeat 500 times
0079FB1D0 00000000 00000000 2C000000 C1020201  [...........,....]
0079FB1E0 7A6A0404 012C6368 03C10202 687A6A04  [..jzhc,......jzh]
0079FB1F0 02012C62 0402C102 61687A6A 783A0605  [b,......jzha..:x]
Block header dump:  0x0140000e
 Object id on Block? Y
 seg/obj: 0xc89c  csc: 0x00.877e0  itc: 2  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1400009 ver: 0x01 opc: 0
     inc: 0  exflg: 0
 
 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0004.01a.00000127  0x0080070c.00ab.20  --U-    3  fsc 0x0000.0008783a
0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000
 
data_block_dump,data header at 0x79f9264
===============
tsiz: 0x1f98
hsiz: 0x18
pbl: 0x079f9264
bdba: 0x0140000e
     76543210
flag=--------
ntab=1
nrow=3
frre=-1
fsbo=0x18
fseo=0x1f77
avsp=0x1f5f
tosp=0x1f5f
0xe:pti[0]      nrow=3  offs=0
0x12:pri[0]     offs=0x1f8d
0x14:pri[1]     offs=0x1f82
0x16:pri[2]     offs=0x1f77
block_row_dump:
tab 0, row 0, @0x1f8d
tl: 11 fb: --H-FL-- lb: 0x1  cc: 2
col  0: [ 2]  c1 02
col  1: [ 4]  6a 7a 68 61
tab 0, row 1, @0x1f82
tl: 11 fb: --H-FL-- lb: 0x1  cc: 2
col  0: [ 2]  c1 03
col  1: [ 4]  6a 7a 68 62
tab 0, row 2, @0x1f77
tl: 11 fb: --H-FL-- lb: 0x1  cc: 2
col  0: [ 2]  c1 04
col  1: [ 4]  6a 7a 68 63
end_of_block_dump
End dump data blocks tsn: 6 file#: 5 minblk 14 maxblk 14
10、找出jzhb存放的位置与偏移量
BBED> find /c jzhb--/c表示数值、find /x表示十六进制
 File: /u01/app/oracle/oradata/test01.dbf (5)
 Block: 14               Offsets: 8173 to 8191           Dba:0x0140000e
------------------------------------------------------------------------
 6a7a6862 2c000202 c102046a 7a686102 06827f 
JZH@ORCL>select * from t;


        ID NAME
---------- ------------------------------
         1 jzha
         2 jzhb
11、把jzhb改成jzhc


BBED> modify /x 6a7a6863
 File: /u01/app/oracle/oradata/test01.dbf (5)
 Block: 14               Offsets: 8173 to 8191           Dba:0x0140000e
------------------------------------------------------------------------
 6a7a6863 2c000202 c102046a 7a686102 06827f 


 <32 bytes per line>


BBED> sum apply
Check value for File 5, Block 14:
current = 0x5a48, required = 0x5a48
12、查询数据

 JZH@ORCL>alter system flush buffer_cache;

 System altered.

JZH@ORCL>select * from t;


        ID NAME
---------- ------------------------------
         1 jzha
         2 jzhc
已经改过来了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10271187/viewspace-1128045/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-02-11

  • 博文量
    113
  • 访问量
    514476