分区索引笔记(四)--分区索引什么时候会失效及处理(三)
,index_name,STATUS from dba_ind_partitions where index_name='IDX1_TEST05';
INDEX_OWNER INDEX_NAME STATUS
------------------------------ ------------------------------ --------
SYS IDX1_TEST05 UNUSABLE
SYS IDX1_TEST05 USABLE
SYS IDX1_TEST05 UNUSABLE
7. 测试truncate partition 对全局索引和本地索引的影响。
Truncate partition 就像truncate table 一样,直接从头部截断数据。在不指定update indexes 子句的情况下,truncate partition 也会造成分区所在表的global 索引失效。语法非常简单:
alter table tbname truncate partition/subpartition ptname;
alter table test04 truncate partition p6 ;
查询
select * from dba_indexes where index_name='PK_ID' ;
select * from dba_ind_partitions where index_name='IDX1_TEST04' ;
发现global index索引失效,本地分区索引状态都是USABLE .
8. 其他操作如 Merge Partitions,Exchange Partitions及coalesce partitions等较少使用,这里不做测试。
其实总之,如果发生数据移动,那么索引肯定是需要注意的。