一.  DB(Data block)

 

A data block is the smallest unit of storage in an Oracle database. Every database has a default block size (specified when the database is created), although blocks in different tablespaces may have different block sizes.

An extent consist of one or more contiguous Oracle data blocks. A block determines the finest level of granularity of where data can be stored. One data block corresponds to a specific number of bytes of physical space on disk.

Information about data blocks can be retrieved from the data dictionary views USER_SEGMENTS and USER_EXTENTS. These views show how many blocks are allocated for database object and how many blocks are available(free) in a segment/extent.

1.1 Dumping data blocks

Start by getting the file and block number to dump. Example:

SQL> SELECT

2    dbms_rowid.rowid_relative_fno(rowid) REL_FNO,

3    dbms_rowid.rowid_block_number(rowid) BLOCKNO,

4    dbms_rowid.rowid_row_number(rowid) ROWNO,

5    empno, ename

6  FROM emp WHERE empno = 7369;

REL_FNO    BLOCKNO      ROWNO      EMPNO ENAME

---------- ---------- ---------- ---------- ----------

4         20          0       7369 SMITH

Dump the block:

SQL> alter system dump datafile 4 block 20;

System altered.

Look for the newly created dump file in your UDUMP directory.

-- dump 多个blocks

Use the following syntax to dump multiple blocks:

ALTER SYSTEM dump datafile <file_id> block min <block_id> block max <block_id+blocks-1>;

1.2  Analyzing data block dumps

From the above block dump:

block_row_dump:

tab 0, row 0, @0x1d49

tl: 38 fb: --H-FL-- lb: 0x0  cc: 8

col  0: [ 3]  c2 4a 46

col  1: [ 5]  53 4d 49 54 48

col  2: [ 5]  43 4c 45 52 4b

col  3: [ 3]  c2 50 03

col  4: [ 7]  77 b4 0c 11 01 01 01

col  5: [ 2]  c2 09

col  6: *NULL*

col  7: [ 2]  c1 15

Converting back to table values:

Col 0 (EMPNO)

SQL> SELECT utl_raw.cast_to_number(replace(''c2 4a 46'','' '')) value FROM dual;

VALUE

----------

7369

Col 2 (ENAME) - simply convert the hex values to ascii - 53 4d 49 54 48 -> SMITH. Alternatively:

SQL> SELECT utl_raw.cast_to_varchar2(replace(''53 4d 49 54 48'','' '')) value FROM dual;

VALUE

---------

SMITH

二.  DBA(Data Block Address)

A Data Block Address (DBA) is the address of an Oracle data block for access purposes.

DBA一般指绝对数据块地址. rowid用来表示一行的物理地址,一行唯一确定一个rowid,并且在使用中一般不会改变,除非rowid之后在行的物理位置发生改变的情况下才会发生变化。在rowid 中,就有一段是来表示DBA的。有关rowid的内容,参考我的Blog:

Oracle Rowid 介绍

http://www.linuxidc.com/Linux/2011-07/37998.htm

2.1 Find the DBA for a given row

Start by getting the file and block number of the row. Example:

SQL> SELECT

2    dbms_rowid.rowid_relative_fno(rowid) REL_FNO,

3    dbms_rowid.rowid_block_number(rowid) BLOCKNO,

4    empno, ename

5  FROM emp WHERE empno = 7369;

REL_FNO    BLOCKNO      EMPNO ENAME

---------- ---------- ---------- ----------

4         20       7369 SMITH

2.2 convert the file and block numbers to a DBA address:

SQL> variable dba varchar2(30)

SQL> exec :dba := dbms_utility.make_data_block_address(4, 20);

PL/SQL procedure successfully completed.

SQL> print dba

DBA

--------------------------------

16777236

2.3  Convert a DBA back to file and block numbers

Example:

SQL> SELECT dbms_utility.data_block_address_block(16777236) "BLOCK",

2         dbms_utility.data_block_address_file(16777236) "FILE"

3    FROM dual;

BLOCK       FILE

---------- ----------

20          4

三.  RDBA(Tablespace relative database block address)

在讲RDBA 之前,要先了解下rowid的组成。 关于rowid的内容,参考我的blog:

Oracle Rowid 介绍

http://blog.csdn.net/tianlesoftware/archive/2009/12/16/5020718.aspx

RDBA是相对数据块地址,是数据字典(表空间及一些对象定义)所在块的地址。

oracle 8以后,rowid的存储空间扩大到了10个字节(32bit object#+10bit rfile#+22bit block#+16bit row#)。rdba就是rowid中的rfile#+block#。

SYS@anqing1(rac1)> SELECT

rowid,

dbms_rowid.rowid_relative_fno(rowid) REL_FNO,

dbms_rowid.rowid_block_number(rowid) BLOCKNO,

dbms_rowid.rowid_row_number(rowid) ROWNO,

empno, ename

FROM scott.emp WHERE empno = 7521;

ROWID      REL_FNO    BLOCKNO      ROWNO   EMPNO ENAME

------------------ ---------- ---------- ---------- ---------- ----------

AAAMfMAAEAAAAAgAAA    4      32      0       7369 SMITH

rowid = AAAMfMAAEAAAAAgAAA

BlockNo= 4

rowno =0

把这个block dump到trace:

SYS@anqing1(rac1)> alter system dump datafile 4 block 32;

System altered.

查看当前的trace 文件位置:

SYS@anqing1(rac1)> oradebug setmypid;

Statement processed.

SYS@anqing1(rac1)> oradebug tracefile_name

/u01/app/oracle/admin/anqing/udump/anqing1_ora_19997.trc

查看trace file:

[oracle@rac1 ~]$ cat /u01/app/oracle/admin/anqing/udump/anqing1_ora_19997.trc

*** 2011-06-07 11:02:30.023

Start dump data blocks tsn: 4 file#: 4 minblk 32 maxblk 32

buffer tsn: 4 rdba: 0x01000020 (4/32)   -- rdba 的值

scn: 0x0000.0006bfdb seq: 0x10 flg: 0x06 tail: 0xbfdb0610

frmt: 0x02 chkval: 0x26a0 type: 0x06=trans data

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x0ED09400 to 0x0ED0B400

ED09400 0000A206 01000020 0006BFDB 06100000  [.... ...........]

ED09410 000026A0 00180001 0000C7CC 0006BFD9  [.&..............]

.....

ED094A0 00000000 00000000 00000000 00000000  [................]

Repeat 465 times

ED0B1C0 00000000 08012C00 2350C203 4C494D06  [.....,....P#.MIL]

ED0B1D0 0552454C 52454C43 4EC2034B B6770753  [LER.CLERK..NS.w.]

....

ED0B3E0 05485449 52454C43 50C2034B B4770703  [ITH.CLERK..P..w.]

ED0B3F0 0101110C 09C20201 15C102FF BFDB0610  [................]

Block header dump:  0x01000020

Object id on Block? Y

seg/obj: 0xc7cc  csc: 0x00.6bfd9  itc: 2  flg: E  typ: 1 - DATA

brn: 0  bdba: 0x1000019 ver: 0x01 opc: 0

inc: 0  exflg: 0

Itl           Xid                  Uba         Flag  Lck        Scn/Fsc

0x01   0x0003.011.000000f2  0x00805794.00c8.49  --U-   14  fsc 0x0000.0006bfdb

0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000

data_block_dump,data header at 0xed09464

===============

tsiz: 0x1f98

hsiz: 0x2e

pbl: 0x0ed09464

bdba: 0x01000020

76543210

flag=--------

ntab=1

nrow=14

frre=-1

fsbo=0x2e

fseo=0x1d61

avsp=0x1d33

tosp=0x1d33

0xe:pti[0]      nrow=14 offs=0  -- 该块中保存了14条记录。从row 0到row 13

0x12:pri[0]     offs=0x1f72

0x14:pri[1]     offs=0x1f47

0x16:pri[2]     offs=0x1f1c

0x18:pri[3]     offs=0x1ef3

0x1a:pri[4]     offs=0x1ec6

0x1c:pri[5]     offs=0x1e9d

0x1e:pri[6]     offs=0x1e74

0x20:pri[7]     offs=0x1e4c

0x22:pri[8]     offs=0x1e26

0x24:pri[9]     offs=0x1dfb

0x26:pri[10]    offs=0x1dd5

0x28:pri[11]    offs=0x1daf

0x2a:pri[12]    offs=0x1d88

0x2c:pri[13]    offs=0x1d61

block_row_dump:

tab 0, row 0, @0x1f72

tl: 38 fb: --H-FL-- lb: 0x1  cc: 8

col  0: [ 3]  c2 4a 46

col  1: [ 5]  53 4d 49 54 48

col  2: [ 5]  43 4c 45 52 4b

col  3: [ 3]  c2 50 03

col  4: [ 7]  77 b4 0c 11 01 01 01

col  5: [ 2]  c2 09

col  6: *NULL*

col  7: [ 2]  c1 15

tab 0, row 1, @0x1f47

tl: 43 fb: --H-FL-- lb: 0x1  cc: 8

col  0: [ 3]  c2 4b 64

col  1: [ 5]  41 4c 4c 45 4e

col  2: [ 8]  53 41 4c 45 53 4d 41 4e

col  3: [ 3]  c2 4d 63

col  4: [ 7]  77 b5 02 14 01 01 01

col  5: [ 2]  c2 11

col  6: [ 2]  c2 04

col  7: [ 2]  c1 1f

tab 0, row 2, @0x1f1c

tl: 43 fb: --H-FL-- lb: 0x1  cc: 8

col  0: [ 3]  c2 4c 16

col  1: [ 4]  57 41 52 44

col  2: [ 8]  53 41 4c 45 53 4d 41 4e

col  3: [ 3]  c2 4d 63

col  4: [ 7]  77 b5 02 16 01 01 01

col  5: [ 3]  c2 0d 33

col  6: [ 2]  c2 06

col  7: [ 2]  c1 1f

tab 0, row 3, @0x1ef3

...

tab 0, row 13, @0x1d61

tl: 39 fb: --H-FL-- lb: 0x1  cc: 8

col  0: [ 3]  c2 50 23

col  1: [ 6]  4d 49 4c 4c 45 52

col  2: [ 5]  43 4c 45 52 4b

col  3: [ 3]  c2 4e 53

col  4: [ 7]  77 b6 01 17 01 01 01

col  5: [ 2]  c2 0e

col  6: *NULL*

col  7: [ 2]  c1 0b

end_of_block_dump

End dump data blocks tsn: 4 file#: 4 minblk 32 maxblk 32

[oracle@rac1 ~]$

/* Formatted on 2011/6/7 11:27:10 (QP5 v5.163.1008.3004) */

SELECT DBMS_UTILITY.data_block_address_file (

TO_NUMBER (LTRIM (''0x01000020'', ''0x''), ''xxxxxxxx''))

AS file_no,

DBMS_UTILITY.data_block_address_block (

TO_NUMBER (LTRIM (''0x01000020'', ''0x''), ''xxxxxxxx''))

AS block_no

FROM DUAL;

FILE_NO   BLOCK_NO

---------- ----------

4         32

这个和我们之前在rowid里查看的一致。

刚才说了,在32这个块里保存了14条row记录,我们继续查询一下我们where=7521 那条:

tab 0, row 13, @0x1d61

SYS@anqing1(rac1)> select DBMS_UTILITY.data_block_address_block (TO_NUMBER (LTRIM (''0x1d61'', ''0x''),''xxxxxxxx'')) as block_no from dual;

BLOCK_NO

----------

7521

我们查询的那条row记录在最后一条。

dba 和 rdba 转载的更多相关文章

  1. DB restore point and datagurad

    ######## 12.5.1 Flashing Back a Physical Standby Database to a Specific Point-in-Time The following ...

  2. Oracle bbed使用说明2---常用命令

    一.BBED常用命令说明 先看帮助的说明 BBED> help all SET DBA [ dba | file#, block# ] SET FILENAME 'filename' SET F ...

  3. 阿里云资深DBA专家罗龙九:云数据库十大经典案例分析【转载】

    阿里云资深DBA专家罗龙九:云数据库十大经典案例分析 2016-07-21 06:33 本文已获阿里云授权发布,转载具体要求见文末 摘要:本文根据阿里云资深DBA专家罗龙九在首届阿里巴巴在线峰会的&l ...

  4. [转载]腾讯专家:论高级DBA的自我修养

    作者介绍: 张秀云:2007年开始从事运维方面的工作,经历过网络管理员.linux运维工程师.DBA.分布式存储运维等多个IT职位.对linux运维.mysql数据库.分布式存储有丰富的经验.2012 ...

  5. Oracle学习笔记—connect、resource和dba三种权限(转载)

    转载自: connect.resource和dba三种标准角色: 授权语句: grant connect ,resource,dba to user with admin option; (注意:其中 ...

  6. [转载]DBA的特质第二部分:性格

    本文转自http://www.searchdatabase.com.cn/showcontent_84382.htm 支持原创.尊重原创,分享知识! 在本系列文章中,笔者将谈一谈数据库管理员(DBA) ...

  7. [转载]DBA的特质第一部分:技术

    本文转自http://www.searchdatabase.com.cn/showcontent_84379.htm 支持原创.尊重原创,分享知识! 在本系列文章中,笔者将谈一谈数据库管理员(DBA) ...

  8. DBA_Oracle DBA常用表汇总(概念)--转载

    https://www.cnblogs.com/eastsea/p/3799411.html  一.与权限相关的字典 ALL_COL_PRIVS表示列上的授权,用户和PUBLIC是被授予者 ALL_C ...

  9. 人人都是 DBA(XII)查询信息收集脚本汇编

    什么?有个 SQL 执行了 8 秒! 哪里出了问题?臣妾不知道啊,得找 DBA 啊. DBA 人呢?离职了!!擦!!! 程序员在无处寻求帮助时,就得想办法自救,努力让自己变成 "伪 DBA& ...

随机推荐

  1. P3128 [USACO15DEC]最大流Max Flow(LCA+树上差分)

    P3128 [USACO15DEC]最大流Max Flow 题目描述 Farmer John has installed a new system of  pipes to transport mil ...

  2. 洛谷P1250种树(贪心)

    题目描述 一条街的一边有几座房子.因为环保原因居民想要在路边种些树.路边的地区被分割成块,并被编号成1..N.每个部分为一个单位尺寸大小并最多可种一棵树.每个居民想在门前种些树并指定了三个号码B,E, ...

  3. 基于Android SDK安装PhoneGap框架

    下载zip文件PhoneGap 2.0.0 PhoneGap 2.0.0 Released 20 Jul 2012http://phonegap.com/download/ 解压缩后的目录结构:Dir ...

  4. jQuery里$.post请求,后台返回结果为“json”格式,前台解析错误问题记录

    在JSP页面使用$.post请求后台返回json数据时,在最后 必须加上返回数据格式为json的才行.不然JSP页面解析会出错.

  5. easyui datagrid 高度布局自适应

    最近在把以前写的一个项目改成用easyui做前端.过程中遇到了不少问题.其中一个就是datagrid不能很好的布局.想了好多办法都有局限.最后想到会不会是布局(easyui-layout)的问题,经过 ...

  6. 简述UIDatePicker的用法

    1.Locale 设置DatePicker的地区,即设置DatePicker显示的语言. 1.跟踪所有可用的地区,取出想要的地区 NSLog(@"%@", [NSLocale av ...

  7. [ ZJOI 2006 ] Mahjong

    \(\\\) \(Description\) 现有权值分别为\(1\text~100\)的\(100\)种牌,分别给出每种排的张数\(A_i\),试判断能否胡牌,胡牌需要将所有牌不重不漏地分成以下几类 ...

  8. ZUK 22(Z2131) 免解锁BL 免rec 保留数据 Magisk Xposed 救砖 ROOT ZUI 4.0.199

    >>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ...

  9. Canvas——基本入门

    基本概念 1.canvas 是 HTML5 提供的一个用于展示绘图效果的标签. canvas 原意画布, 帆布. 在 HTML 页面中用于展示绘图效果. 最早 canvas 是苹果提出的一个方案, 今 ...

  10. jQuery——事件操作

    事件绑定 1.简单事件绑定 $("button").click(function () {})//可重复绑定,不会被层叠 2.bind():不推荐使用 $("button ...