Skip to Main Content
  • Questions
  • Moving partitioned table and index to multiple tablespaces

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Elaine.

Asked: August 02, 2018 - 5:34 pm UTC

Last updated: August 03, 2018 - 3:45 pm UTC

Version: 12.1.0.2

Viewed 1000+ times

You Asked

I have a 10 billion row table, partitioned 32 ways. Each partition is located in a separate tablespace. Each of the 12 local partitioned indexes occupies its own tablespace as well (yes, total of 44 tablespaces).

We are moving all application tables to TDE. So there will be 44 new encrypted tablespaces into which we will be moving just this one table and its indexes.

I cannot encrypt the existing tablespaces because that is a 12.2 feature and we are still at 12.1

I know that i can use alter table ... move for the small tables - there are about 30 - 50k at any one point in time. I can use sql to generate the move SQL for those and their indexes.

I know that I can use DBMS_REDEFINITION for the partitioned tables that occupy a single tablespace and they can remain online during the move.

Is there a way to use DBMS_REDEFINITION to move my huge 32 partition table? Would i use the package to do it and just move one partition at a time? What happens to the indexes given that each would need to be moved to a different tablespace.

Assuming there is a way to do this using DBMS_REDEFINITION, what is the performance impact of having a table where it partially exists in an encrypted tablespace and partially in an unencrypted tablespace? (does oracle care?)

and Chris said...

No need to use dbms_redefinition. You can move partitions online in 12.1!

create tablespace new_tblsp datafile 'new_tblsp.dbf' size 10m;

create table t (
  c1 int, 
  c2 int
) partition by hash ( c1 ) (
  partition p1, partition p2
);

insert into t 
  select level, level from dual
  connect by level <= 100;
  
commit;

create index li on t ( c2 ) local;

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

PARTITION_NAME   TABLESPACE_NAME   
P1               USERS             
P2               USERS    

alter table t move partition p1 tablespace new_tblsp update indexes online;

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

PARTITION_NAME   TABLESPACE_NAME   
P1               NEW_TBLSP         
P2               USERS   


It's regular tables that you can't move online until 12.2...

drop table t cascade constraints purge;
create table t (
  c1 int, 
  c2 int
);

insert into t 
  select level, level from dual
  connect by level <= 100;
  
commit;

alter table t move online;

ORA-01735: invalid ALTER TABLE option


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database