暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 使用alter table对表进行分区时的索引

ASKTOM 2020-09-09
551

问题描述

你好,汤姆,

如果我们使用alter命令对非分区表进行分区,那么非分区表上的索引是否也将被分区?

提前感谢

专家解答

我猜你是说12.2的表...修改分区命令。

如果是这样,请使用update indexes子句说明它们是本地的还是全局的。对于全局索引,您可以对基表使用不同的分区方案:

create table t (
  c1 int, c2 int, c3 int
);

create index i1 on t ( c1 );
create index i2 on t ( c2 );
create index i3 on t ( c3 );

alter table t
  modify partition by range ( c1 ) 
  interval ( 100 ) (
    partition p0 values less than ( 101 )
  ) update indexes (
    i1 local,
    i2 global,
    i3 global 
      partition by hash ( c3 ) 
      partitions 4
  );
  
select index_name, partitioned 
from   user_indexes
where  table_name = 'T';

INDEX_NAME    PARTITIONED   
I1            YES            
I2            NO             
I3            YES 

select index_name, partition_name 
from   user_ind_partitions;

INDEX_NAME    PARTITION_NAME   
I1            P0                
I3            SYS_P2660         
I3            SYS_P2661         
I3            SYS_P2662         
I3            SYS_P2663         

文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论