[20190918]shrink space与ORA-08102错误.txt

1.环境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

2.再现ORA-08102错误:

SCOTT@test01p> create table t(x int, pad varchar2(100)) enable row movement;
Table created.

SCOTT@test01p> insert /*+ append*/  into t select level, lpad('x', 100, 'x') from dual connect by level<=1e4;
10000 rows created.

SCOTT@test01p> alter table t add y int default 10 not null;
Table altered.

SCOTT@test01p> create index i_t_xy on t(x,y);
Index created.

SCOTT@test01p> delete t where x<=5000;
5000 rows deleted.

SCOTT@test01p> commit ;
Commit complete.

SCOTT@test01p> alter table t shrink space;
alter table t shrink space
*
ERROR at line 1:
ORA-08102: index key not found, obj# 27979, file 11, block 2445 (2)

SCOTT@test01p> host  oerr ora 8102
08102, 00000, "index key not found, obj# %s, file %s, block %s (%s)"
// *Cause:  Internal error: possible inconsistency in index
// *Action:  Send trace file to your customer support representative, along
//           with information on reproducing the error

3.10046跟踪看看.
SCOTT@test01p> alter session set events '10046 level 12';
Session altered.

SCOTT@test01p> alter table t shrink space;
alter table t shrink space
*
ERROR at line 1:
ORA-08102: index key not found, obj# 27979, file 11, block 2445 (2)

SCOTT@test01p> alter session set events '10046 off';
Session altered.

--//检查转储发现:
oer 8102.2 - obj# 27979, rdba: 0x02c0098d(afn 11, blk# 2445)
kdk key 8102.2:
  ncol: 3, len: 12
  key: (12):  03 c2 64 31 ff 06 02 c0 1d a5 00 00
  mask: (2048):
--//通过bbed观察看看.
--//03 c2 64 31 ,03表示长度.后面3位表示oracle数字.

SCOTT@test01p> @ conv_n c26431
       N20
----------
      9948

BBED> set dba 11,2446
        DBA             0x02c0098e (46139790 11,2446)
--//注:windows下bbed,无法识别10g以上版本的os头,block存在+1的偏移.

BBED> map
 File: D:\APP\ORACLE\ORADATA\TEST\TEST01P\USERS01.DBF (11)
 Block: 2446                                  Dba:0x02c0098e
------------------------------------------------------------
 KTB Data Block (Index Leaf)
 struct kcbh, 20 bytes                      @0
 struct ktbbh, 72 bytes                     @20
 struct kdxle, 32 bytes                     @100
 b2 kd_off[399]                             @132
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ub1 freespace[822]                         @930
 ub1 rowdata[6380]                          @1752
 ub4 tailchk                                @8188

BBED> x /rnnx *kd_off[3]
rowdata[6352]                               @8104
-------------
flag@8104:     0x00 (NONE)
lock@8105:     0x00
data key:
col    0[3] @8107: 9583
col    1[2] @8111: 10
col    2[6] @8114:  0x02  0xc0  0x1d  0x9f  0x00  0x19

--//9948-9583+3 = 368

BBED> x /rnnx *kd_off[368]
rowdata[516]                                @2268
------------
flag@2268:     0x00 (NONE)
lock@2269:     0x00
data key:
col    0[3] @2271: 9948
col    1[2] @2275: 10
col    2[6] @2278:  0x02  0xc0  0x1d  0xa5  0x00  0x00

BBED> x /rxxx *kd_off[368]
rowdata[516]                                @2268
------------
flag@2268:     0x00 (NONE)
lock@2269:     0x00
data key:
col    0[3] @2271:  0xc2  0x64  0x31
col    1[2] @2275:  0xc1  0x0b
col    2[6] @2278:  0x02  0xc0  0x1d  0xa5  0x00  0x00
--//可以看出原来的key是 03 c2  64 31 02 c1  0b 06 02 c0 1d a5 00 00
--//而shrink space后,索引的键值发生了变化,变为如下:
--//key: (12):  03 c2 64 31 ff 06 02 c0 1d a5 00 00
--//0xff表示NULL,参考链接:http://blog.itpub.net/267265/viewspace-2120439/=>[20160619]NULL在数据库的存储.txt
--//也就是索引的第2字段oracle认为是NULL,也就是遇到这样的情况shrink space时.oracle错误的认为Y=null,
--//因为这样的情况Y=10的值并没有保存在数据块中,而是放在sys.ecol$中.

SCOTT@test01p> SELECT *  FROM sys.ecol$ WHERE tabobj# IN (SELECT DATA_OBJECT_ID FROM dba_objects WHERE owner = USER AND object_name = 'T');
   TABOBJ#     COLNUM BINARYDEFVAL                     GUARD_ID
---------- ---------- ------------------------------ ----------
     27978          3 C10B
--//c10b对应number类型是数字10.
--//对于这样的情况如果要降低HWM,仅仅ctas建立表以及索引.
--//如果增加字段时写入数据块中,应该不会出现这样的情况.看了一下隐含参数,应该是_add_col_optim_enabled.
SYS@test> @ hide _add_col_optim_enabled
NAME                   DESCRIPTION                        DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE ISSES ISSYS_MOD
---------------------- ---------------------------------- ------------- ------------- ------------ ----- ---------
_add_col_optim_enabled Allows new add column optimization TRUE          TRUE          TRUE         TRUE  IMMEDIATE

SCOTT@test01p> alter session set "_add_col_optim_enabled"=false;
Session altered.

create table t1(x int, pad varchar2(100)) enable row movement;
insert /*+ append*/  into t1 select level, lpad('x', 100, 'x') from dual connect by level<=1e4;
alter table t1 add y int default 10 not null;
create index i_t1_xy on t1(x,y);
delete t1 where x<=5000;
commit ;
alter table t1 shrink space;

SCOTT@test01p> alter table t1 shrink space;
Table altered.
--//当然这样增加字段就很慢!!

总结:
如果要做shrink space,最好先检查看看是否曾经这样增加过新字段.

[20190918]shrink space与ORA-08102错误.txt的更多相关文章

  1. [20181122]模拟ORA-08103错误.txt

    [20181122]模拟ORA-08103错误.txt $ oerr ora 810308103, 00000, "object no longer exists"// *Caus ...

  2. 【转载】alter table move 和 alter table shrink space的区别

    move 和shrink 的共同点1.收缩段2.消除部分行迁移3.消除空间碎片4.使数据更紧密 shrink 语法:  alter table TABLE_NAME shrink space [com ...

  3. [20180904]工作中一个错误.txt

    [20180904]工作中一个错误.txt --//昨天看我提交一份修改建议,发现自己写的sql语句存在错误.--//链接:http://blog.itpub.net/267265/viewspace ...

  4. [20170914]tnsnames.ora的管理.txt

    [20170914]tnsnames.ora的管理.txt --//昨天朋友讲tnsnams.ora的内容太长了,而且许多不需要的.管理不方便.我记得以前写[20150409]tnsnames.ora ...

  5. Oracle shrink space

    一.开启表的行迁移 alter table table_name enable row movement; select 'alter table '||s.owner||'.'||s.table_n ...

  6. No space left on device错误解决

    No space left on device错误解决笔记 今天准备重启下数据库(linux oracle11g) conn /as sysdba; 出现这样的错误No space left on d ...

  7. SHRINK SPACE Command : Online Segment Shrink for Tables, LOBs and IOTs

    ORACLE-BASE - ALTER TABLE ... SHRINK SPACE Command : Online Segment Shrink for Tables, LOBs and IOTs ...

  8. Oracle中shrink space命令

    shrink_clause:   http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_3001.htm#i2192484 ...

  9. ubuntu 上运行的django 出现No space left on device错误

    运行django出现错误信息: [2016-02-16 14:33:24,476 pyinotify ERROR] add_watch: cannot watch /usr/local/lib/pyt ...

随机推荐

  1. Access Editor Settings 访问编辑器设置

    This topic demonstrates how to access editors in a Detail View using a View Controller. This Control ...

  2. 如何获取input,file里的文件,实现预览效果,并传给后端?

    单纯的事件与获取 <input type="file" name="file" id="fileUpload"> <img ...

  3. [转]How to enable macros in Excel 2016, 2013, and 2010

    本文转自:https://www.ablebits.com/office-addins-blog/2014/07/22/enable-macros-excel/#always-run-macros T ...

  4. vue slot内容分发

    当需要让组件组合使用,混合父组件的内容和子组件的模板的时候,就会用到slot.这个过程就叫内容分发. 最为常用的是两种slot:一种是匿名slot, 一种是具名slot. 匿名 很好理解: 就是默认, ...

  5. Linux下使用 github+hexo 搭建个人博客01-hexo搭建

    为什么要搭建自己的博客系统? 原因有好几个吧,归类如下:1.自己搭建博客系统很有成就感,可以自己选定页面风格和页面排版: 2.自己搭建博客系统可以根据自己的需要添加各种插件功能,因此整体上比网上的第三 ...

  6. 命令模式彻底删除oracle实例

    步骤一:关闭数据库export ORACLE_SID=bgsp1. sqlplus / as sysdba2. shutdown immediate步骤二:删除实例相关文件1. find $ORACL ...

  7. ORACLE等待事件:read by other session

    read by other session简介 官方关于read by other session的介绍如下: When information is requested from the datab ...

  8. vs code 运行 Django 怎么修改端口

    1.具体操作步骤如下 默认情况下,通过 python manage.py runserver 命令行模式默认打开是 8000 端口,如下图所示: 在浏览器预览效果如下: 为了防止端口冲突,我们一般会修 ...

  9. 初级模拟电路:3-9 BJT三极管实现逻辑门

    回到目录 BJT晶体管可以实现逻辑门,事实上,在场效应管被发明用于集成电路以前,各种逻辑门芯片中的电路就是用BJT晶体管来实现的.最早人们使用二极管与BJT组合来实现逻辑门,这个称为二极管-晶体管逻辑 ...

  10. NXP_RTCESL库

    恩智浦实时控制嵌入式软件库(缩写为RTCESL,以前为恩智浦嵌入式软件库FSLESL)是一组算法,从基础数学运算到高级数学变换以及高级观测器,这些都可以方便地用在复杂的实时控制应用中以及我们的电机控制 ...