[每日一题] 11gOCP 1z0-052 :2013-09-27 bitmap index.................................................C37
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12106027
正确答案C
这道题目是需要我们掌握位图索引知识点。
一、首先我们来看位图索引的组成
位图索引由Key、Start ROWID、End ROWID、Bitmap组成,如下图所示:
二、其次我们来看位图索引适用范围
1.适用于低基数列
2.更新键列的成本非常高
3.使用 OR/AND/NOT IN/COUNT(*) 谓词进行查询时效率较
三、最后我们来分析这道题为什么选C
1:
bitmap 索引是分段存储的,也就是说很多条记录可能是分做了N段来存储,也就是有N个begin/end,当新的记录 insert 而使用以前未曾使用过的物理地址的时候,会产生一个bitmap 段来存储,就算只有一条记录
2: 当删除一条记录的时候,在bitmap索引上做了一个delete 的标记并用一新的记录来标记了,下面请看具体的演示
3: 当 dml发生的时候,会lock住某个值的存储bit的那一rowid所在的记录,参考下面的 row 中lock ,这样显然会影响并发
4、实验验证
(1)创建表
gyj@OCM> Create table gyj_bitmap_t1(id int ,name varchar2(10)); Table created.
(2)插入数据
gyj@OCM> Begin
2 For i in 1 .. 10000 loop
3 Insert into gyj_bitmap_t1 values(i,'AAAAA');
4 Commit;
5 end loop;
6 End;
7 / PL/SQL procedure successfully completed.
gyj@OCM> Begin
2 For i in 10001 .. 20000 loop
3 Insert into gyj_bitmap_t1 values(i,'BBBBB');
4 Commit;
5 end loop;
6 End;
7 /
(3)创建位图索引
gyj@OCM> create bitmap index b_idx_t1 on gyj_bitmap_t1(name); Index created.
(4)在125号会话下修改id=1的一行数据
gyj@OCM> select sid from v$mystat where rownum=1; SID
----------
125 gyj@OCM> Update gyj_bitmap_t1 set name='BBBBB' where id=1; 1 row updated.
(5)在125号会话下修改id=10001的一行数据,结果被阻塞了。。。
gyj@OCM> select sid from v$mystat where rownum=1; SID
----------
149 gyj@OCM> Update gyj_bitmap_t1 set name='AAAAA' where id=10001;Update
(6)查看锁
sys@OCM> select * from v$lock where sid in(125,149); ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK
---------------- ---------------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
00000000910D8760 00000000910D87B8 125 AE 100 0 4 0 1177 0
00000000910D9118 00000000910D9170 149 TX 65541 1235 0 4 194 0
00000000910DA1D0 00000000910DA228 149 AE 100 0 4 0 480 0
00002B7A1402D830 00002B7A1402D890 125 TM 77552 0 3 0 212 0
00002B7A1402D830 00002B7A1402D890 149 TM 77552 0 3 0 194 0
000000008FB03048 000000008FB030C0 125 TX 65541 1235 6 0 212 1
000000008FB1F928 000000008FB1F9A0 149 TX 131093 1616 6 0 194 0
可以看出149号会话请求4号锁,一直没有持有,这个4号锁是什么呢,锁的标记符是:TX -65541 -1235,从这里可以分析出是在哪个回滚段的第几个事务槽。
sys@OCM> select to_char('65541','xxxxxxxxxxxx') from dual; TO_CHAR('6554
-------------
10005
转化成0001和0005即1号回滚段的第5号事务槽上。
我去dump一下这个1号回滚段的段头(上面有事务表信息)
sys@OCM> select * from v$rollname where usn=1; USN NAME
---------- ------------------------------
1 _SYSSMU1_1240252155$ sys@OCM> alter system dump undo header "_SYSSMU1_1240252155$"; System altered.
(7)转储出来的事务表如下:
Undo block address=0x00c00576,转化成地址是:3号文件的1398号块
sys@OCM> alter system dump datafile 3 block 1398;
System altered.
(8)转储出undo信息:
(9) 通过undo链接这里一层层往前找到事务开始:
*-----------------------------
* Rec #0x1e slt: 0x05 objn: 77552(0x00012ef0) objd: 77552 tblspc: 7(0x00000007)
* Layer: 11 (Row) opc: 1 rci 0x00
Undo type: Regular undo Begin trans Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000Ext idx: 0
flg2: 0
*-----------------------------
uba: 0x00c00576.0145.1d ctl max scn: 0x0000.00243640 prv tx scn: 0x0000.00243658
txn start scn: scn: 0x0000.00243606 logon user: 90
prev brb: 12584309 prev bcl: 0
KDO undo record:
KTB Redo
op: 0x04 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: L itl: xid: 0x000a.018.00000495 uba: 0x00c007b8.015a.15
flg: C--- lkc: 0 scn: 0x0000.0023aa8c
KDO Op code: URP row dependencies Disabled
xtype: XAxtype KDO_KDOM2 flags: 0x00000080 bdba: 0x018000c7 hdba: 0x018000c2
itli: 2 ispac: 0 maxfr: 4858
tabn: 0 slot: 0(0x0) flag: 0x2c lock: 0 ckix: 0
ncol: 2 nnew: 1 size: 0
Vector content:
col 1: [ 5] 41 41 41 41 41 *-----------------------------
* Rec #0x1f slt: 0x05 objn: 77553(0x00012ef1) objd: 77553 tblspc: 7(0x00000007)
* Layer: 10 (Index) opc: 22 rci 0x1e
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
index undo for leaf key operations
KTB Redo
op: 0x04 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: L itl: xid: 0xffff.000.00000000 uba: 0x00000000.0000.00
flg: C--- lkc: 0 scn: 0x0000.002435d3
Dump kdilk : itl=2, kdxlkflg=0x1 sdc=0 indexid=0x1c0008a block=0x01c0008b
(kdxlup): update keydata in row
key :(1469):
05 41 41 41 41 41 06 01 80 00 c3 00 00 06 01 80 00 db 01 3f 85 a7 cf ff ff
ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf
ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff
ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff
ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff
ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff
ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff
cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff
cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff
0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff
ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cd ff ff ff ff ff 07 ff 19 ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff
cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff
ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf
ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff
ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff
ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff
ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff
cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff
ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf
ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cc ff ff ff ff 0f ff 77 ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff
ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff
ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff
ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff
cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff
ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff
ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff
ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf
ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cc ff ff ff ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff
ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff
ff 0f ff 1a ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff
ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff
ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cc ff ff ff ff 0f ff b1 02
ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff
ff cf ff ff ff ff ff ff ff ff cf ff ff ff ff ff ff ff 01 *-----------------------------
* Rec #0x20 slt: 0x05 objn: 77553(0x00012ef1) objd: 77553 tblspc: 7(0x00000007)
* Layer: 10 (Index) opc: 37 rci 0x1f
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
index undo for leaf key operations
index change (kdxIndexlogicalNonkeyUpdate): count=6
KTB Redo
op: 0x02 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C uba: 0x00c00576.0145.1f
Dump kdilk : len=29 != sizeof(kdilk)=20 :(29):
26 02 05 00 8a 00 c0 01 8b 00 c0 01 00 00 00 00 00 00 00 00 00 04 02 02 00
00 00 00 00
itl=2, kdxlkflg=0x5 sdc=0 indexid=0x1c0008a block=0x01c0008b
(kdxIndexLogicalNonkeyUpdate): index logical nonkey update
ncol: 4 nvec: 2 nnew: 2 size: 0
unique key: (13): 05 41 41 41 41 41 06 01 80 00 c3 00 00
logical nonkey columns operation records:
column 2:
atom same length replace: from offset 0 replace 6 bytes:
01 80 00 db 01 3f
column 3:
atom replace: from offset 279 replace 10 bytes with 10 bytes:
ff 1a ff ff ff ff ff ff ff ff *-----------------------------
* Rec #0x21 slt: 0x05 objn: 77553(0x00012ef1) objd: 77553 tblspc: 7(0x00000007)
* Layer: 10 (Index) opc: 22 rci 0x20
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
index undo for leaf key operations
KTB Redo
op: 0x02 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C uba: 0x00c00576.0145.20
Dump kdilk : itl=2, kdxlkflg=0x1 sdc=0 indexid=0x1c0008a block=0x01c0008b
(kdxlpu): purge leaf row
key :(21):
05 42 42 42 42 42 06 00 00 00 00 00 00 06 00 00 00 00 00 00 ff *-----------------------------
* Rec #0x22 slt: 0x05 objn: 77553(0x00012ef1) objd: 77553 tblspc: 7(0x00000007)
* Layer: 10 (Index) opc: 37 rci 0x21
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
index undo for leaf key operations
index change (kdxIndexlogicalNonkeyUpdate): count=6
KTB Redo
op: 0x02 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: C uba: 0x00c00576.0145.21
Dump kdilk : len=29 != sizeof(kdilk)=20 :(29):
26 02 05 00 8a 00 c0 01 8b 00 c0 01 00 00 00 00 00 00 00 00 00 04 02 02 fa
ff 00 00 00
itl=2, kdxlkflg=0x5 sdc=0 indexid=0x1c0008a block=0x01c0008b
(kdxIndexLogicalNonkeyUpdate): index logical nonkey update
ncol: 4 nvec: 2 nnew: 2 size: -6
unique key: (13): 05 42 42 42 42 42 06 00 00 00 00 00 00
logical nonkey columns operation records:
column 2:
atom same length replace: from offset 0 replace 6 bytes:
00 00 00 00 00 00
column 3:
atom delete: from offset 0 delete 6 bytes
(10)我们来dump一下id=1和id=10001这两行所在的数据块的数据。
gyj@OCM> select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block from gyj_bitmap_t1 where id in(1,10001); FILE# BLOCK
---------- ----------
6 199
6 219
(11)转储6号文件199号块
sys@OCM> alter system dump datafile 6 block 199; System altered.
gyj@OCM> select UTL_RAW.CAST_TO_NUMBER(replace('c1 02',' ')) from dual; UTL_RAW.CAST_TO_NUMBER(REPLACE('C3020102',''))
----------------------------------------------
1 gyj@OCM> select UTL_RAW.CAST_TO_VARCHAR2(REPLACE('42 42 42 42 42',' ')) from dual; UTL_RAW.CAST_TO_VARCHAR2(REPLACE('4141414141',''))
----------------------------------------------------------------------------------
BBBBB
(11)转储6号文件219号块
gyj@OCM> select UTL_RAW.CAST_TO_NUMBER(replace('c3 02 01 02',' ')) from dual; UTL_RAW.CAST_TO_NUMBER(REPLACE('C3020102',''))
----------------------------------------------
10001 gyj@OCM> select UTL_RAW.CAST_TO_VARCHAR2(REPLACE('41 41 41 41 41',' ')) from dual; UTL_RAW.CAST_TO_VARCHAR2(REPLACE('4141414141',''))
----------------------------------------------------------------------------------
AAAAA
具体这个不再说了,需要有一定的基础!!!
QQ:252803295
技术交流QQ群:
DSI&Core Search Ⅰ 群:127149411(2000人技术群:未满)
DSI&Core Search Ⅱ 群:177089463(1000人技术群:未满)
DSI&Core Search Ⅲ 群:284596437(500人技术群:未满)
DSI&Core Search Ⅳ 群:192136702(500人技术群:未满)
DSI&Core Search Ⅴ 群:285030382(500人闲聊群:未满)
MAIL:dbathink@hotmail.com
BLOG: http://blog.csdn.net/guoyjoe
WEIBO:http://weibo.com/guoyJoe0218
ITPUB: http://www.itpub.net/space-uid-28460966.html
OCM: http://education.oracle.com/education/otn/YGuo.HTM
[每日一题] 11gOCP 1z0-052 :2013-09-27 bitmap index.................................................C37的更多相关文章
- [每日一题] 11gOCP 1z0-052 :2013-09-1 RMAN-- repair failure........................................A20
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10859315 正确答案:D 一.模拟上题的错误: 1.删除4号文件 [oracle@myd ...
- [每日一题] 11gOCP 1z0-053 :2013-10-9 backup with the KEEP option....................................33
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12517603 正确答案:AB 在Oracle 11g中,可以使用backup ….keep ...
- [每日一题] 11gOCP 1z0-053 :2013-10-12 RESULT_CACHE在哪个池?.............................44
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12657479 正确答案:B Oracle 11g 新特性:Result Cache , ...
- [每日一题] 11gOCP 1z0-052 :2013-08-31 数据库的存储结构....................................................A8
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10784599 . 正确答案:A 将逻辑存储与物理存储分开是关系数据库范例的必要部分.关系数 ...
- [每日一题] 11gOCP 1z0-052 :2013-09-19 创建用户...................................................B41
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11834661 正确答案:BC 这道题比较简单,我就以答案来解析,如下来自官方文档创建用户的 ...
- [每日一题] 11gOCP 1z0-052 :2013-09-17 DRA--Data Recovery Advisor.............................B31
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11818529 正确答案:AD 数据库恢复顾问(DRA)是一个诊断和修复数据库问题的工具.共 ...
- [每日一题] 11gOCP 1z0-052 :2013-09-5 runInstaller oracle of no swap
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11186995 正确答案:A 我们先来看下面这张截图,这是我在安装Oracle 11.2.0 ...
- [每日一题] 11gOCP 1z0-053 :2013-10-11 Flashback Data Archive属性.........................43
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12656897 正确答案:BD 闪回数据归档请参考:http://blog.csdn.net ...
- [每日一题] 11gOCP 1z0-053 :2013-10-7 the backup of MULT_DATA................................32
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12500579 正确答案:D RMAN 的新增功能 对超大型文件应用 Intraf ...
- [每日一题] 11gOCP 1z0-052 :2013-09-2 ADDM(Automatic Database Diagnostic Monitor)...................A28
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10951207 正确答案:BC AWR简称Automatic Workload Reposi ...
随机推荐
- C#_Test
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Plus ...
- 新浪微博登陆,获取token
用WeiboAuthListener获取code 用下面的代码获取token..半成品的sdk真让人捉急. String code = values.getString("code" ...
- 用java实现Simsimi小黄鸡接口
package com.iask.webchat.chatmachine; import java.io.BufferedReader; import java.io.InputStream; imp ...
- Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash
A. DZY Loves Hash time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 正则表达式JSP实例
<%@ page language="java" import="java.util.*,cn.com.Person,cn.com.Adddress" p ...
- [ES6] Rest Parameter
Problem with the ES5: function displayTags(){ for (let i in arguments) { let tag = arguments[i]; _ad ...
- 你的sscanf用对了吗
用sscanf解析输入字符串 我们平常编写的很多应用程序都会处理各种各样的输入,这些输入或来自本地文件,或来自网络,或来自用户的输入.今天,让我们来看看sscanf这个和字符串相关的函数可能给你带来的 ...
- 服务 通话录音 TelephonyManager
MainActivity public class MainActivity extends ListActivity { private BatteryChangedReceiver rec ...
- DataGrid( 数据表格) 组件[6]
本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...
- .net对文件的操作之文件读写
读写文件的步骤一般需要5步: 创建文件流 创建读写器 执行读或写的操作 关闭读写器 关闭文件流 需要引用:System.IO这个命名空间 代码演示: string path = @"F:\a ...