分析和解决 ORA-01502: index '某分区表索引名' or partition of such index is in unusable state
2013-01-14 14:33
211 查看
最近工作中遇到一个Oracle的数据库问题
逻辑背景:
由于Performance 原因重构一些数据库表(其中包含了一些分区数据表) 同级联删除旧的index 和 新建了index.
程序执行:
1 check and truncate by partition (DDL)
2 bacth insert
问题现象:
步骤2出现 java.sql.SQLException: java.sql.BatchUpdateException: ORA-01502: index 'A' or partition of such index is in unusable state
分析:
debug 到步骤1 完:
select status from user_indexes where index_name in ( 'A', 'A2‘); 发现状态变为 unusable.
DB上rebuild unusable的index, such as:
alter index A rebuild;
alter index A2 rebuild;
继续执行步骤2 无exception.
查询相关分区表的所有索引状况:
ALTER TABLE A表
ADD CONSTRAINT A PRIMARY KEY(主键字段);
CREATE INDEX A2 ON A表(索引字段);
其他分区表:
ALTER TABLE B表
ADD CONSTRAINT B PRIMARY KEY(主键字段)
USING INDEX LOCAL;
CREATE INDEX B2 ON B表(索引字段) LOCAL;
由于本人不是DBA,所以采取了比较分析的办法,大致找到解决办法。 重建分区索引加上Local, 因为重建表的分析索引时脚本丢失了这个关键字。
根本原因:
和DBA沟通后得知。 当我们的表为分区表的时候, 所有用到与分区字段有关的 索引要创建为 本地索引。 否则, 默认为全局索引, 这样一旦有相关的 更新分区数据的DDL (比如 步骤1中执行的是:alter table
A表 truncate partition for (分区ID)。) 造作会导致这样的全局索引失效。
逻辑背景:
由于Performance 原因重构一些数据库表(其中包含了一些分区数据表) 同级联删除旧的index 和 新建了index.
程序执行:
1 check and truncate by partition (DDL)
2 bacth insert
问题现象:
步骤2出现 java.sql.SQLException: java.sql.BatchUpdateException: ORA-01502: index 'A' or partition of such index is in unusable state
分析:
debug 到步骤1 完:
select status from user_indexes where index_name in ( 'A', 'A2‘); 发现状态变为 unusable.
DB上rebuild unusable的index, such as:
alter index A rebuild;
alter index A2 rebuild;
继续执行步骤2 无exception.
查询相关分区表的所有索引状况:
ALTER TABLE A表
ADD CONSTRAINT A PRIMARY KEY(主键字段);
CREATE INDEX A2 ON A表(索引字段);
其他分区表:
ALTER TABLE B表
ADD CONSTRAINT B PRIMARY KEY(主键字段)
USING INDEX LOCAL;
CREATE INDEX B2 ON B表(索引字段) LOCAL;
由于本人不是DBA,所以采取了比较分析的办法,大致找到解决办法。 重建分区索引加上Local, 因为重建表的分析索引时脚本丢失了这个关键字。
根本原因:
和DBA沟通后得知。 当我们的表为分区表的时候, 所有用到与分区字段有关的 索引要创建为 本地索引。 否则, 默认为全局索引, 这样一旦有相关的 更新分区数据的DDL (比如 步骤1中执行的是:alter table
A表 truncate partition for (分区ID)。) 造作会导致这样的全局索引失效。
相关文章推荐
- OGG-00665 (status = 1502-ORA-01502: index 'index' or partition of such index is in unusable state)
- ORA-01502: index 'INDEX_NAME' or partition of such index is in unusable state
- ORA-01502: index ‘index_name' or partition of such index is in unusable state
- Index XXX or partition of such index is in unusable state
- ORA-14517: Subpartition of index "string.string" is in unusable state
- 解决 C++错误 error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no
- the project file '' has been renamed or is no longer in the solution 解决办法
- @synthesize of 'weak' property is only allowed in ARC or GC mode
- ORA-06553:PLS-306:wrong number or types of arguments in call to ''
- Implicit delcaration of function 'sysctlbyname'is invalid in c99 问题及解决办法
- ORA-06553: PLS-306: wrong number or types of arguments in call to 'xxxxxxx(proceduresName)'
- redefinition of `struct in6_addr' 的解决办法
- fatal error C1083: Cannot open include file: 'htmlhelp.h': No such file or directory 解决办法
- two or more data types in declaration of `main'
- 生成JNI的DLL时提示找不到jni.h的解决的方法Cannot open include file: 'jni.h': No such file or directory
- Error(30,13): PLS-00323: subprogram or cursor 'XXXXX' is declared in a package spec
- 初学C++:编译器报错“Cannot open include file: 'iostream.h': No such file or directory”的解决方法
- Spring配置文件加载时出现Bean property 'newscontentDAO' is not writable or has an invalid setter method错误的解决
- Notice: Use of undefined constant out - assumed 'out' in D:wampwwwdaoruindex.php on line 4解决办法
- Android 解决adb server is out of date. killing... ADB server didn't ACK * failed to star