是否可以在区间分区中声明单独的表空间?

问题描述 投票:1回答:1

我有一个专用的数据表空间和一个专用的索引表空间。我将表迁移到区间分区表并在单独的表空间上重建索引。然后新记录进入表中,创建新的间隔分区。

我的问题是分区及其索引都是在数据专用表空间上创建的,而不是:

  • 数据专用表空间上的数据
  • 索引专用表空间的索引

是否有不需要持续维护的解决方案?

oracle indexing partition tablespace
1个回答
3
投票

您可以更改索引的默认属性。然后,新分区将使用您指定的分区:

create tablespace table_data 
  datafile 'table_data.dbf' size 1M autoextend on;

create tablespace index_data 
  datafile 'index_data.dbf' size 1M autoextend on;

create table t (
  c1 int, c2 int
) partition by range ( c1 ) 
  interval ( 1 ) (
  partition p0 values less than ( 1 )
) tablespace table_data;

create index i on t ( c2 ) local;

insert into t values ( 1, 1 );
commit;

select partition_name, tablespace_name 
from   user_tab_partitions
where  table_name = 'T';

PARTITION_NAME   TABLESPACE_NAME   
P0               TABLE_DATA        
SYS_P622         TABLE_DATA     

select partition_name, tablespace_name  
from   user_ind_partitions
where  index_name = 'I';

PARTITION_NAME   TABLESPACE_NAME   
P0               TABLE_DATA        
SYS_P622         TABLE_DATA        

alter index i 
  modify default attributes tablespace index_data;

insert into t values ( 2, 2 );
commit;

select partition_name, tablespace_name 
from   user_tab_partitions
where  table_name = 'T';

PARTITION_NAME   TABLESPACE_NAME   
P0               TABLE_DATA        
SYS_P622         TABLE_DATA        
SYS_P623         TABLE_DATA     

select partition_name, tablespace_name  
from   user_ind_partitions
where  index_name = 'I';

PARTITION_NAME   TABLESPACE_NAME   
P0               TABLE_DATA        
SYS_P622         TABLE_DATA        
SYS_P623         INDEX_DATA    
© www.soinside.com 2019 - 2024. All rights reserved.