[20160405]bbed的assign命令.txt

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

时间: 2024-11-09 04:00:18

[20160405]bbed的assign命令.txt的相关文章

[20160405]bbed修改文件头.txt

[20160405]bbed修改文件头.txt --以前做过一次,重复测试: http://blog.itpub.net/267265/viewspace-746222/ 如果数据库数据文件损坏,并且archivelog损坏,这样无法完全恢复,如果仅仅某个数据文件的scn与其他文件不同步,导致该数据文件无法mount. 正常可以像odu之类的工具恢复.但是在实际上如果修改数据文件的scn保持同步,这样数据库可以正常打开,选择常规的方法imp/exp以及expdp/impdp 方式恢复,这样虽然丢

[20170412]bbed隐藏数据记录.txt

[20170412]bbed隐藏数据记录.txt --上午做了bbed恢复修改记录(不等长)的情况,http://blog.itpub.net/267265/viewspace-2137082/ --下午做一个隐藏数据记录的情况,实际上这样做有点多余,就是删除命令,看看bbed是否可以完成. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER --------------------

[20170411]bbed计算redo检查和.txt

[20170411]bbed计算redo检查和.txt --前一阵子做测试,需要一个计算器做异或的操作,链接http://blog.itpub.net/267265/viewspace-2134945/ --正好前几天开会遇到熟人,谈起我写的脚本很实用.我说不支持管道操作不是很好,对方讲支持,他自己就是这样用的. $ cat ~/bin/xor.sh #! /bin/bash # just play , calc xor!! s='0' for i in $(cat $1| tr 'a-f' '

[20160526]bbed修复删除记录.txt

[20160526]bbed修复删除记录.txt --以前也做过,链接: http://blog.itpub.net/267265/viewspace-745944/ --自己当时完全是依葫芦画瓢,许多东西理解不深刻,重新做一次. 1.环境: 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ --------------

[20170705]理解linux su命令.txt

[20170705]理解linux su命令.txt --//我一般在维护时经常使用root用户登录,然后su - oracle 转到其他用户操作 --//一般都加入 - 参数.这个已经成了条件反射...^_^. # man su       Change the effective user id and group id to that of USER. -, -l, --login make the shell a login shell --//也就是使用login里面的shell,设置

[20150902]rman的list archivelog命令.txt

[20150902]rman的list archivelog命令.txt --昨天同事要查询2015/8/13号日志,要确定需要检查日志的范围: RMAN> list archivelog all  completed between '2015-08-13' and '2015-08-13 18:00:00'; List of Archived Log Copies for database with db_unique_name xxxxxx ========================

[20161129]奇怪的转储命令.txt

[20161129]奇怪的转储命令.txt --如果你转储文件头使用如下命令: SYS@book> alter system dump datafile 6  block 1; System altered. Start dump data blocks tsn: 8 file#:6 minblk 1 maxblk 1 Block 1 (file header) not dumped:use dump file header command End dump data blocks tsn: 7

[20140411]windows的forfiles命令.txt

[20140411]windows的forfiles命令.txt 大家知道在linux/unix下删除特定时间以前的文件是find+rm命令来操作,在windows下有一个forfiles命令可以完成. C:\Windows\SysWOW64>forfiles.exe /? FORFILES [/P pathname] [/M searchmask] [/S]          [/C command] [/D [+ | -] {yyyy/MM/dd | dd}] 描述:     选择一个文件(

[20130727]linux下使用taskset命令.txt

[20130727]linux下使用taskset命令.txt # rpm -qilf `which taskset`Name        : schedutils                   Relocations: (not relocatable)Version     : 1.4.0                             Vendor: Red Hat, Inc.Release     : 2                             Build