[20170611]关于数据块地址的计算.txt

--//如果数据库出现一些问题,会在alert或者跟踪文件,或者屏幕出现一些错误提示.例如:

ORA-00600: internal error code, arguments: [2662], [3], [392066208], [3], [392066212], [4194825], [], [], [], [], [], []

ORA-600 [2662] [a] [b] {c} [d] [e]
Arg [a] Current SCN WRAP
Arg [b] Current SCN BASE
Arg {c} dependent SCN WRAP
Arg [d] dependent SCN BASE
Arg [e] Where present this is the DBA where the dependent SCN came from.

--//这里第5个参数4194825就是dba也就是数据块地址.
--//实际上简单的计算很简单,32位占4个字节,前10位表示文件号,后22位表示:

SYS@test> select round(&dba/power(2,22),0) file# ,mod(&&dba,power(2,22)) block# from dual ;
old   1: select round(&dba/power(2,22),0) file# ,mod(&&dba,power(2,22)) block# from dual
new   1: select round(4194825/power(2,22),0) file# ,mod(4194825,power(2,22)) block# from dual
     FILE#     BLOCK#
---------- ----------
         1        521

--//我自己常用的脚本:
$ cat dfb10.sql
select
dbms_utility.data_block_address_file(&1) rfile#,
dbms_utility.data_block_address_block(&&1) block#
from dual;

select 'alter system dump datafile '||dbms_utility.data_block_address_file(&1)||' block '||
dbms_utility.data_block_address_block(&&1) ||' ;' text

$ cat dfb16.sql
column text format a60

select
dbms_utility.data_block_address_file(to_number(substr('&&1',3),'xxxxxxxxxxxxxxxx')) rfile#,
dbms_utility.data_block_address_block(to_number(substr('&&1',3),'xxxxxxxxxxxxxxxx')) block#,
'alter system dump datafile '||dbms_utility.data_block_address_file(to_number(substr('&1',3),'xxxxxxxxxxxxxxxx'))||' block '|| dbms_utility.data_block_address_block(to_number(substr('&&1',3),'xxxxxxxxxxxxxxxx')) ||' ;' text
from dual;

--//convert file#,block# 到 dba地址.
$ cat convrdba.sql
select
 TO_CHAR (dbms_utility.make_data_block_address(&1,&2), 'xxxxxxxxxxxxx') rdba16,
dbms_utility.make_data_block_address(&&1,&&2) rdba
from dual;

--//还有1种方法就是bbed,直接输入例子:

BBED> set dba 1,521
        DBA             0x00400209 (4194825 1,521)

BBED> set dba 4194825
        DBA             0x00400209 (4194825 1,521)

BBED> set dba 0x00400209
        DBA             0x00400209 (4194825 1,521)

--//下午无聊,想完善以前[20121207]vim中使用bc做10与16进制计算.txt,链接http://blog.itpub.net/267265/viewspace-750731/
--//源代码http://www.vim.org/scripts/script.php?script_id=219,我修改加入10,16进制的计算,
--//作者这么多年2017/04/17 更新.以此为基础加入10,16进制转化,以及dba转化为file#,block#.
--//这次修改代码加入dba的计算.同时修复了windows下的许多问题.

--//做一些简单说明,这个版本仅仅工作在windows版本.bc的安装可以下载UnxUtils.zip包,设置好PATH路径就ok了.
--//我注解 let str = escape (str, '*();&><|^') ,这样运算存在*以及(),不再存在问题.
--//以前旧版本不支持幂运算(^),windows的转化4个^才能正确执行.

--//简单操作:
a3

在数字a3上面输入\10,相当于a3当作16进制数据,给出结果=163.
在数字a3处于选择模式,输入;10,相当于a3当作16进制数据,在提示行上给出答案
(注:windows下要处于可视模式,不能处于选择模式,使用ctrl+g切换)

123
在数字123上面输入\16,相当于123当作10进制数据,给出结果=0x7b.
在数字123处于选择模式,输入;16,相当于123当作10进制数据,在提示行上给出答案

\bx 可以进行行运算
\bc 在提示行输出结果.

;bc 选中文本,然后ctrl+g,输入;bc,在提示行输出结果.

\22
;22

--//参考10,16进制的计算,计算dba转化为file#,block#.
--//做一个操作例子:
4194825 = set dba 1,521
--//打入\22,输出如下:
4194825 = set dba 1,521

==================修改后代码如下:
"" calculate expression entered on command line and give answer, e.g.:
" :Calculate sin (3) + sin (4) ^ 2
command! -nargs=+ Calculate echo "<args> = " . Calculate ("<args>")

"" calculate expression from selection, pick a mapping, or use the Leader form
"vnoremap ;bc "ey`>:call CalcLines()<CR>
"vnoremap <Leader>bc "ey`>:call<SID>CalcBC(1)<CR>
vnoremap ;bc "ey`>:call CalcLines(0)<CR>
vnoremap ;10 "ey`>:call CalcLines(10)<CR>
vnoremap ;16 "ey`>:call CalcLines(16)<CR>
vnoremap ;22 "ey`>:call CalcLines(22)<CR>
vnoremap ;32 "ey`>:call CalcLines(32)<CR>

"" calculate expression on current line, pick a mapping, or use the Leader
nnoremap  <Leader>bc "eyy$:call CalcLines(0)<CR>
nnoremap   <Leader>bx <Esc>A=<Esc>"eyy:call CalcLines(0)<CR>
nnoremap   <Leader>10 <Esc>A=<Esc>"eyy:call CalcLines(10)<CR>
nnoremap   <Leader>16 <Esc>A=<Esc>"eyy:call CalcLines(16)<CR>
nnoremap   <Leader>22 <Esc>A=<Esc>"eyy:call CalcLines(22)<CR>
nnoremap   <Leader>32 <Esc>A=<Esc>"eyy:call CalcLines(32)<CR>

"nnoremap  <Leader>bc "eyy$:call<SID>CalcBC(0)<CR>

"" calculate from insertmode
inoremap =: = <Esc>"eyy:call CalcLines()<CR>a

" ---------------------------------------------------------------------
"  Calculate:
"    clean up an expression, pass it to bc, return answer
function! Calculate (s,flag)

let str = a:s

" remove newlines and trailing spaces
    let str = substitute (str, "\n",   "", "g")
    let str = substitute (str, '\s*$', "", "g")

" sub common func names for bc equivalent
    let str = substitute (str, '\csin\s*(',  's (', 'g')
    let str = substitute (str, '\ccos\s*(',  'c (', 'g')
    let str = substitute (str, '\catan\s*(', 'a (', 'g')
    let str = substitute (str, "\cln\s*(",   'l (', 'g')
    let str = substitute (str, '\clog\s*(',  'l (', 'g')
    let str = substitute (str, '\cexp\s*(',  'e (', 'g')

" alternate exponitiation symbols
    let str = substitute (str, '\*\*', '^', "g")
    let str = substitute (str, '`', '^',    "g")
    let str = substitute (str, '\^', '^^^^',    "g")

" escape chars for shell
    " let str = escape (str, '*();&><|^')

let preload = exists ("g:bccalc_preload") ? g:bccalc_preload : ""

" run bc
    " return str
    " let answer = system ("echo " . str . " \| bc -l " . preload)

if a:flag == 0
         let answer = system ("echo " . str . " \| bc -l " . preload)
    endif
    if a:flag == 16
         let answer = system ("echo obase=16 ;" . str .  " \| bc -l " . preload)
         let answer = "0x" . tolower ( answer )
    endif
    if a:flag == 10
         let str = toupper ( str )
         let answer = system ("echo ibase=16 ;" . str .  " \| bc -l " . preload)
    endif
    if a:flag == 22
         let answer = system ("echo " . str . "/4194304" . " \| bc " . preload)
         let answer1 = system ("echo " . str . "%4194304" . " \| bc " . preload)
         let answer = " set dba " . answer . "," . answer1
    endif

if a:flag == 32
         let answer = system ("echo " . str . "/4294967296" . " \| bc " . preload)
         let answer1 = system ("echo " . str . "%4294967296" . " \| bc " . preload)
         let answer = " scn_wrap,scn_base: " . answer . " " . answer1
    endif

" strip newline
    let answer = substitute (answer, "\n", "", "g")

" strip trailing 0s in decimals
    let answer = substitute (answer, '\.\(\d*[1-9]\)0\+', '.\1', "")

return answer
endfunction

" ---------------------------------------------------------------------
" CalcLines:
"
" take expression from lines, either visually selected or the current line,
" pass to calculate function, echo or past answer after '='
function! CalcLines(flag)

let has_equal = 0

" remove newlines and trailing spaces
    let @e = substitute (@e, "\n", "",   "g")
    let @e = substitute (@e, '\s*$', "", "g")

" if we end with an equal, strip, and remember for output
    if @e =~ "=$"
        let @e = substitute (@e, '=$', "", "")
        let has_equal = 1
    endif

" if there is another equal in the line, assume chained equations, remove
    " leading ones
    let @e = substitute (@e, '^.\+=', '', '')

let answer = Calculate (@e,a:flag)

" append answer or echo
    if has_equal == 1
        exec "normal a" . answer
    else
        echo "answer = " . answer
    endif
endfunction

[20170611]关于数据块地址的计算.txt的更多相关文章

  1. Oracle数据块深入分析总结

    http: 最近在研究块的内部结构,把文档简单整理了一下,和大家分享一下.该篇文章借助dump和BBED对数据 库内部结构进行了分析,最后附加了一个用BBED解决ORA-1200错误的小例子.在总结的 ...

  2. ORACLE 数据块dump

    1. rdba(Tablespace relative database block address) 是相对数据块地址,是数据所在的地址,rdba可就是rowid 中rfile#+block#. 根 ...

  3. Oracle 数据块损坏与恢复具体解释

    1.什么是块损坏: 所谓损坏的数据块,是指块没有採用可识别的 Oracle 格式,或者其内容在内部不一致. 通常情况下,损坏是由硬件故障或操作系统问题引起的.Oracle 数据库将损坏的块标识为&qu ...

  4. ORA-01578: ORACLE 数据块损坏 (文件号 10, 块号 57896)ORA-01110: 数据文件 10: '/data/oradata/prod35.dbf'

    https://community.oracle.com/thread/3540795 概述 ------------- 数据库坏块(corruption) 的类型可以按照坏块所属对象的不同,分为用户 ...

  5. 定义一个共享数据块DB1 在DB1中定义一个数组 用程序 访问数据里面的某一个成员或者地址连续的成员

    提纲 : 定义一个共享数据块 DB1 在DB1 中定义数组 用SFC21 实现 实现全部数组元素的赋一样的值 实现 给数组中的某一个元素赋值 实现 对数组中的全部元素赋值 实现将数组中的某个 或者 某 ...

  6. zw版_Halcon图像交换、数据格式、以及超级简单实用的DIY全内存计算.TXT

    zw版_Halcon图像交换.数据格式.以及超级简单实用的DIY全内存计算.TXT Halcon由于效率和其他原因,内部图像采用了很多自有格式,提高运行速度,但在数据交换方面非常麻烦. 特别是基于co ...

  7. Oracle 摘去数据块的面纱

    Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F 00018000h 6 A2 0 0 0c 0 80 3 8b 61 15 0 0 0 3 4 type frmt spa ...

  8. Ext2文件系统布局,文件数据块寻址,VFS虚拟文件系统

    注:本分类下文章大多整理自<深入分析linux内核源代码>一书,另有参考其他一些资料如<linux内核完全剖析>.<linux c 编程一站式学习>等,只是为了更好 ...

  9. 使用BBED理解和修改Oracle数据块

    1.生成bbed list file文件: SQL> select file#||' '||name||' '||bytes from v$datafile; $ vim dbfile.txt ...

随机推荐

  1. Spring系列之DI的原理及手动实现

    目录 Spring系列之IOC的原理及手动实现 Spring系列之DI的原理及手动实现 前言 在上一章中,我们介绍和简单实现了容器的部分功能,但是这里还留下了很多的问题.比如我们在构造bean实例的时 ...

  2. CentOS7.0小随笔——运行级别

    一.Linux运行级别(通用) 0:关机(halt) 1:单用户模式(无需用户名和密码的登录,用于紧急维护系统时用,类似于Windows中的安全模式) 2:不启用网络功能的多用户模式 3:启用网络功能 ...

  3. 使用 trash 避免 rm -rf 悲剧

    昨晚做了一个令人痛心疾首的操作,rm -rf something,把我个人电脑里的重要文件夹给删掉了,懵逼了半天才缓过来.还好是个人文件,不对公司造成影响.这件事也让我意识到 rm -rf 确实是个高 ...

  4. VisualVM远程连接Tomcat

    最近项目已经要提测了,有时间来考虑一些性能上的事儿了.之前拜读过<深入理解java虚拟机>,只可惜当时功力尚浅,有些东西还是不太懂,而且应用场景也没有,所以借这次机会看看.当然了,这次并不 ...

  5. [转]如何在Angular4中引入jquery

    本文转自:https://blog.csdn.net/home_zhang/article/details/77992734 1.anjq是我的项目名称: 在anjq目录下打开dos命令窗口,然后依次 ...

  6. Spring Day 2

    **Spring框架的IOC之注解方式的快速入门** 步骤一:导入注解开发所有需要的jar包 步骤二:创建对应的包结构,编写Java的类:接口到实现类 步骤三:在src的目录下,创建applicati ...

  7. 转:VB中的API详解

    在接下来的这篇文章中,我将向大家介绍.NET中的线程API,怎么样用C#创建线程,启动和停止线程,设置优先级和状态. 在.NET中编写的程序将被自动的分配一个线程.让我们来看看用C#编程语言创建线程并 ...

  8. 从零开始学安全(八)●Ubuntu 16 LAMP环境搭建

    1.Apache2 web 服务器的安装 : 可以先更新一下服务器 sudo apt-get update # 获取最新资源包sudo apt-get upgrade # 本机软件全部更新sudo a ...

  9. 【译】《Clean C#》

    本文是<Clean C#>一书译文的序言,阅读译文请移步至:<Clean C#>译文. <Clean C#>的副标题是Readable,Maintainable,P ...

  10. SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe

    问题描述 *************************** APPLICATION FAILED TO START *************************** Description ...