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

1.环境:
[email protected]> @ 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错误:

[email protected]> create table t(x int, pad varchar2(100)) enable row movement;
Table created.

[email protected]> insert /*+ append*/  into t select level, lpad(‘x‘, 100, ‘x‘) from dual connect by level<=1e4;
10000 rows created.

[email protected]> alter table t add y int default 10 not null;
Table altered.

[email protected]> create index i_t_xy on t(x,y);
Index created.

[email protected]> delete t where x<=5000;
5000 rows deleted.

[email protected]> commit ;
Commit complete.

[email protected]> 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)

[email protected]> 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跟踪看看.
[email protected]> alter session set events ‘10046 level 12‘;
Session altered.

[email protected]> 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)

[email protected]> 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数字.

[email protected]> @ 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
-------------
[email protected]:     0x00 (NONE)
[email protected]:     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
------------
[email protected]:     0x00 (NONE)
[email protected]:     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
------------
[email protected]:     0x00 (NONE)
[email protected]:     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$中.

[email protected]> 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.
[email protected]> @ 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

[email protected]> 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;

[email protected]> alter table t1 shrink space;
Table altered.
--//当然这样增加字段就很慢!!

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

原文地址:https://www.cnblogs.com/lfree/p/11552377.html

时间: 2024-10-18 22:52:17

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

oracle中比较alter table t move 和alter table t shrink space

alter table t move和alter table t shrink space都可以用来进行段收缩,降低高水位HWM,也都可以用来消除行链接(Row Chaining)和行迁移(Row Migration),但是有如下区别:1)使用alter table move,会把表格最多收缩到创建表格时的storage子句指定的初始大小,使用alter table shrink space,则不受此限制.2)使用alter table move之后,索引会无效,需要重建,使用alter tab

关于oracle 11g导出数据时 报 ORA 1455错误的处理

由于导出的该用户的表可能存在空数据表,那么可能就会出现此其异常. 首先: 查看: SQL>show parameter deferred_segment_creation; 如果为TRUE,则将该参数改为FALSE: 在sqlplus中,执行如下命令: SQL>alter system set deferred_segment_creation=false; 然后: 可以针对数据表.索引.物化视图等手工分配Extent SQL>Select 'alter table '||table_n

Oracle中shrink space命令

shrink_clause:   http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_3001.htm#i2192484 首先oracle shrink 是10g之后才引出的,有shrink table 和shrink space两种,这里介绍shrink space 压缩分两个阶段: 1.数据重组:这个过程是通过一系列的insert delete操作,将数据尽量排在列的前面进行重新组合. 2.HWM调整:这个过程是对

关于Inodes文件被占满(如何解决linux报No space left on device错误)

原因与解决方法一,磁盘inode被用光导致/data目录下无法创建文件 touch atouch: cannot touch `a': No space left on device磁盘只使用了61%df -hFilesystem Size Used Avail Use% Mounted on.../dev/sda5 817G 466G 310G 61% /data...inode被用光df -iFilesystem Inodes IUsed IFree IUse% Mounted on.../

java.io.IOException: No space left on device 错误

今天碰到比较奇怪的问题: 7/05/14 19:20:24 INFO util.Utils: Fetching http://192.168.31.160:33039/jars/spark_study_java-0.0.1-SNAPSHOT-jar-with-dependencies.jar to /tmp/spark-446068a4-aaa4-4277-b009-908bf0d4ecac/executor-dcc3175b-7d19-4485-81e1-bf31a83a66b4/spark-

ORA 00972 错误处理

Oracle 11G SQL 写好的脚本执行后报错:ORA 00972 标识符过长 个人排查,找到原因: select 语句中的字段别名太长,中文字符别名最长为10个汉字,简化别名名称,问题得到解决. 网上也有其他说法,可能这只是其中的一种情况.后期遇到再补充

linux服务器报No space left on device错误的解决过程记录

起因 今天在本地提交了点代码,但到服务器上git pull的时候提示No space left on device,第一反应是猜想可能硬盘满了(很有可能是log导致的),不过想想又觉得不太可能,这台服务器上只部署了一个应用,查看项目占用空间也不大. 解决过程 1.作为一个linux菜鸟,第一时间百度查关于查看硬盘使用情况的命令 [[email protected] ~]# df -h文件系统 容量 已用 可用 已用% 挂载点/dev/hda1 20G   2.4G  18G 13%  /tmpf

Linux下Apache重启遇到No space left on device错误的解决方法

解决办法:1.输入:ipcs -s 看有没有超过5个,如果有请执行下面2的命令:2.ipcs -s | perl -ane '/^0x00000000/ && `ipcrm -s $F[1]`'3.重启Apache服务.(到此问题解决!)ipcs -s | grep apache | perl -e 'while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}' 网上有人说用上面这条命令或者重启服务器之后也可以解决,没

ORA-10635: Invalid segment or tablespace type

上周星期天在迁移数据时,碰到了ORA-10635: Invalid segment or tablespace type 错误,当时的操作环境如下: 操作系统版本: [[email protected] scripts]$ more /etc/issue Red Hat Enterprise Linux ES release 4 (Nahant Update 6) 数据库版本  : SQL> select * from v$version; BANNER --------------------