oracle 表分区后插入数据报错SQLException: ORA-01502: 索引 'aaaaaa' 或这类索引的分区处于不可用状态

oracle 某张表使用了列hash规则进行了分区,使用过程中插入数据报错:nested exception is java.sql.SQLException: ORA-01502: 索引 'aaaaaa' 或这类索引的分区处于不可用状态。

在解决这个问题前,了解了一下oracle数据库关于分区的几个命令:

1、查看某张表是否有分区

select * from user_tables where table_name='tableaaa'

如果 tablespace_name  为空则证明存在分区。

2、如果存在分区,则需要查看是哪个分区的索引出了问题,根据索引名称,查看分区索引状态

select * from user_ind_partitions where index_name='aaaaaa'

其中发现status有的是UNUSABLE、USABLE两种。第一种应该为不可用,于是找到重建索引的命令。

alter index index_name rebuild partition partition_name (online);
或者alter index index_name rebuild partition partition_name ;

另外如果不是分区索引,重建索引的命令为:

alter index index_name rebuild (online);或者alter index index_name rebuild;

3、执行上述命令后,问题解决。

4、说几条其他相关的命令:

4.1、查看分区的表有哪些,这些表是以什么方式进行的分区:比如Hash、range等等

  select * from user_part_tables;

4.2、查看某张表分区有哪些

  SELECT * FROM USER_TAB_PARTITIONS WHERE TABLE_NAME='tableaaa'

4.3、查看索引对应的列名称

select * from user_ind_columns where index_name='xxx';

4.4、查看某张表有哪些索引,一般和4.3结合使用

select * from user_indexes where table_name='表名'

 

posted @ 2020-07-18 13:43  0o飞行天下o0  阅读(1024)  评论(0编辑  收藏  举报