Thinking Oracle Study Notes (x) partitioned index failed

Here the scene said only the index failed (only affect the global index):
Conclusion: The global index truncate and swap partitions can lead to loss of effect index
Local index partition does not lead to truncate the index fail.
drop table part_tab_trunc purge;
create table part_tab_trunc (id int,col2 int,col3 int,contents varchar2(4000))
        partition by range (id)
        (
        partition p1 values less than (10000),
        partition p2 values less than (20000),
        partition p3 values less than (maxvalue)
        )
        ;
insert into part_tab_trunc select rownum ,rownum+1,rownum+2, rpad('*',400,'*') from dual connect by rownum <=50000;
commit;
create  index idx_part_trunc_col2  on part_tab_trunc(col2) local;
create  index idx_part_trunc_col3  on part_tab_trunc(col3) ;


--- partition truncate ago
select index_name, partition_name, status
  from user_ind_partitions
 where index_name = 'IDX_PART_TRUNC_COL2';
 
 
INDEX_NAME                     PARTITION_NAME                 STATUS
------------------------------ ------------------------------ --------
IDX_PART_TRUNC_COL2            P1                             USABLE
IDX_PART_TRUNC_COL2            P2                             USABLE
IDX_PART_TRUNC_COL2            P3                             USABLE

select index_name, status
  from user_indexes
 where index_name = 'IDX_PART_TRUNC_COL3';

INDEX_NAME                     STATUS
------------------------------ --------
IDX_PART_TRUNC_COL3            VALID

alter table part_tab_trunc truncate partition p1 ;

--- After the partition truncate
select index_name, partition_name, status
  from user_ind_partitions
 where index_name = 'IDX_PART_TRUNC_COL2';
 
 
INDEX_NAME                     PARTITION_NAME                 STATUS
------------------------------ ------------------------------ --------
IDX_PART_TRUNC_COL2            P1                             USABLE
IDX_PART_TRUNC_COL2            P2                             USABLE
IDX_PART_TRUNC_COL2            P3                             USABLE


select index_name, status
  from user_indexes
 where index_name = 'IDX_PART_TRUNC_COL3';


INDEX_NAME                     STATUS
------------------------------ --------
IDX_PART_TRUNC_COL3            UNUSABLE

  

Guess you like

Origin www.cnblogs.com/sunliyuan/p/12307666.html