[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,现在正常了.