[20160405]bbed的assign命令.txt

简介: [20160405]bbed的assign命令.txt --我记得开始学习bbed的时候,看的是一份pdf文档,提到assign的用法,摘要如下: assign The assign command does symbolic assignment, with type and range checking.

[20160405]bbed的assign命令.txt

--我记得开始学习bbed的时候,看的是一份pdf文档,提到assign的用法,摘要如下:

assign

The assign command does symbolic assignment, with type and range checking. Either target or source can be omitted for the
current offset.  For example, the following command assigns structure at current offset to file 4,block 2 's first ITL
entry

BBED> assign dba 4, 2 ktbbhitl[0]

--感觉不是非常灵活,实际上assign非常灵活.
BBED> help assign
ASSIGN[/x|d|u|o] <target spec>=<source spec>
<target spec> : [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
<source spec> : [ value | <target spec options> ]

--使用这个命令,可以避免大小头问题,修改数据块变得非常简单,我感觉许多人都不知道很好的使用assign.通过一个例子来说明:

1.环境:
SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                             TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------- ----------------
    1        13227505290 2016-04-05 12:16:40                7       13227286650 ONLINE              1016 YES /mnt/ramdisk/book/system01.dbf   SYSTEM
    2        13227505290 2016-04-05 12:16:40             1834       13227286650 ONLINE              1012 YES /mnt/ramdisk/book/sysaux01.dbf   SYSAUX
    3        13227505290 2016-04-05 12:16:40           923328       13227286650 ONLINE               932 YES /mnt/ramdisk/book/undotbs01.dbf  UNDOTBS1
    4        13227505290 2016-04-05 12:16:40            16143       13227286650 ONLINE              1016 YES /mnt/ramdisk/book/users01.dbf    USERS
    5        13227505290 2016-04-05 12:16:40           952916       13227286650 ONLINE               929 YES /mnt/ramdisk/book/example01.dbf  EXAMPLE
    6        13227505290 2016-04-05 12:16:40          1314508       13227286650 ONLINE               945 YES /mnt/ramdisk/book/sugar01.dbf    SUGAR
    7        13227505290 2016-04-05 12:16:40      13227207527       13227286650 ONLINE                40 YES /mnt/ramdisk/book/tea01.dbf      TEA
7 rows selected.

2.假设我修改file#=7,CHECKPOINT_CHANGE#=13227505290-1.

select 13227505289,trunc(13227505289/power(2,32)) scn_wrap,mod(13227505289,power(2,32))  scn_base from dual
13227505289     SCN_WRAP     SCN_BASE
------------ ------------ ------------
13227505289            3    342603401

SYS@book> @ &r/10to16  13227505289

10 to 16 HEX   REVERSE16
-------------- -----------------------------------
00003146bb689 0x89b66b14-03000000

BBED> p /x dba 7,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x146bb68a

BBED> p /x dba 1,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x146bb68a

--我可以写成:

BBED> assign dba 7,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas  = 342603401
ub4 kscnbas                                 @484      0x146bb689

BBED> assign dba 7,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas  = 0x146bb689
ub4 kscnbas                                 @484      0x146bb689


SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header where file# in (1,7);
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                            TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- ------------------------------- ---------------
    1        13227505290 2016-04-05 12:16:40                7       13227286650 ONLINE              1016 YES /mnt/ramdisk/book/system01.dbf  SYSTEM
    7        13227505289 2016-04-05 12:16:40      13227207527       13227286650 ONLINE                40 YES /mnt/ramdisk/book/tea01.dbf     TEA

BBED> assign  dba 7,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas  = dba 1,1 kcvfh.kcvfhckp.kcvcpscn.kscnbas
ub4 kscnbas                                 @484      0x146bb68a

--这样就不要考虑大小头的转换,修改更加方便快捷,减少错误的发生.
--再举一个例子,调整scn某个块的scn增加10000,产生ORA-00600: internal error code, arguments: [2662].错误.

SYS@book> select current_scn from v$database ;
CURRENT_SCN
------------
13227510828

SYS@book> select ora_rowscn ,rowid,a.* from scott.empx a where rownum<=1;
  ORA_ROWSCN ROWID                     EMPNO ENAME      JOB                MGR HIREDATE                     SAL         COMM       DEPTNO
------------ ------------------ ------------ ---------- --------- ------------ ------------------- ------------ ------------ ------------
13227501857 AAAWe/AAHAAAACDAAA         7369 ZZZZ       CLERK             7902 1980-12-17 00:00:00          800                        20

select 13227501857,trunc(13227501857/power(2,32)) scn_wrap,mod(13227501857,power(2,32))  scn_base from dual
13227501857     SCN_WRAP     SCN_BASE
------------ ------------ ------------
13227501857            3    342599969

SYS@book> @ &r/rowid AAAWe/AAHAAAACDAAA
      OBJECT         FILE        BLOCK          ROW DBA                  TEXT
------------ ------------ ------------ ------------ -------------------- ----------------------------------------
       92095            7          131            0 7,131                alter system dump datafile 7 block 131 ;

select 13227520828,trunc(13227520828/power(2,32)) scn_wrap,mod(13227520828,power(2,32))  scn_base from dual
13227520828     SCN_WRAP     SCN_BASE
------------ ------------ ------------
13227520828            3    342618940
--比当前多1万.

BBED> set dba 7,131
        DBA             0x01c00083 (29360259 7,131)

BBED> p /d kcbh.bas_kcbh
ub4 bas_kcbh                                @8        342599969

BBED> assign dba 7,131 kcbh.bas_kcbh=342618940;
ub4 bas_kcbh                                @8        0x146bf33c
--直接指定十进制.

BBED> modify /x 3cf3 offset 8190
File: /mnt/ramdisk/book/tea01.dbf (7)
Block: 131      Offsets: 8190 to 8191  Dba:0x01c00083
-------------------------------------------------------
3cf3

<80 bytes per line>
--要颠倒一下,不小心很容易错误,这是不能使用assign dba 7,131 tailchk = 0xf33c0602;,不知道为什么
--BBED> assign dba 7,131 tailchk = 0xf33c0602;
-- BBED-00207: invalid offset specifier (f33c0602)

BBED> p tailchk
ub4 tailchk                                 @8188     0xf33c0602

SYS@book> select ora_rowscn ,rowid,a.* from scott.empx a where rownum<=1;
select ora_rowscn ,rowid,a.* from scott.empx a where rownum<=1
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [2662], [3], [342609366], [3], [342618940], [29360259], [], [], [], [], [], []

SYS@book> Select current_scn from v$database ;
CURRENT_SCN
------------
13227511270

--数据块的scn超前了,需要等一会.

SCOTT@book> select ora_rowscn ,rowid,a.* from scott.empx a where rownum<=1;
  ORA_ROWSCN ROWID                     EMPNO ENAME      JOB                MGR HIREDATE                     SAL         COMM       DEPTNO
------------ ------------------ ------------ ---------- --------- ------------ ------------------- ------------ ------------ ------------
13227501857 AAAWe/AAHAAAACDAAA         7369 ZZZZ       CLERK             7902 1980-12-17 00:00:00          800                        20

SCOTT@book> select current_scn from v$database ;
CURRENT_SCN
------------
13227521335
--ok,现在正常了.

目录
相关文章
|
Oracle 关系型数据库 数据库管理
[20180628]显示bbed x命令格式.txt
[20180628]显示bbed x命令格式.txt --//测试经常使用bbed x命令显示数据,里面的格式每次输入必须显示表结构才方便输入. --//如果字段很多非常麻烦,写一个脚本完成这个工作.
1329 0
|
Oracle 关系型数据库 数据库管理
[20180619]bbed verify问题.txt
[20180619]bbed verify问题.txt --//记录一下自己一个多年的错误. 1.环境: SCOTT@test01p> @ ver1 PORT_STRING                    VERSION        BANNER   ...
1288 0
|
SQL Oracle 关系型数据库
[20180511]PLSQL与fetchsize.txt
[20180511]PLSQL与fetchsize.txt --//测试看看PLSQL中cursor的fetchsize: 1.环境: SCOTT@book> @ ver1 PORT_STRING                    VERSION  ...
1170 0
|
数据库管理
[20180205]使用bbed相关问题.txt
[20180205]使用bbed相关问题.txt --//上个星期5使用bbed修改块遇到一些问题,做一个记录: 1.环境: SCOTT@book> @ ver1 PORT_STRING                    VERSION       ...
968 0
|
Oracle 关系型数据库 数据库管理
[20171124]bbed的使用问题2.txt
[20171124]bbed的使用问题2.txt --//bbed 是探究oracle数据块的好工具,有时候不用转储,直接可以它看oracle内部块的内部结构. --//在使用中要注意一些问题,昨天又犯类似错误,通过例子来说明: SCOTT@book> select rowid,dept.
1282 0
|
Oracle 关系型数据库 Linux
[20171031]rman merge例子2.txt
[20171031]rman merge例子2.txt --//以前做的测试 [20170626]rman merge例子.txt --//链接 http://blog.
1009 0
|
Oracle 关系型数据库 Linux
[20170626]rman merge例子.txt
[20170626]rman merge例子.txt 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER -----------------...
934 0
|
Oracle 关系型数据库 数据库管理
[20161124]bbed使用问题.txt
[20161124]bbed使用问题.txt --最近一致在使用bbed探究oracle数据库,遇到一些问题做一些记录。 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION  ...
905 0
|
Oracle 关系型数据库 开发工具
[20161020]bbed保存执行结果.txt
[20161020]bbed保存执行结果.txt --别人问的问题,实际上如果输出内容不多,直接界面上查看。 --如果输出很多,屏幕显示一闪而过,如果在tmux下使用就很简单,使用前缀键+[进入tmux的buffer模式,浏览以前的显示的内容 --我设置vi模式,可以像vim使用?或者/查询需要找的内容,一般使用?,因为tmux的显示是从下向上的。
764 0
|
Oracle 关系型数据库 数据库
[20160421]backup as copy问题2.txt
[20160421]backup as copy问题2.txt http://blog.itpub.net/267265/viewspace-2070878/ --前面提到使用backup as copy datafile 1 format '/home/orac...
1127 0

热门文章

最新文章