Move tables to a different tbs, the easy way

Mozno sa vam obcas pritrafi, ze potrebujete z nejakeho dovodu presunut velke mnozstvo tabuliek z jedneho tbs do ineho. V pripade ze tabulka nema index je to jednoducha vec, ale ked index ma problemy sa zacinaju. Tento skript sa o vsetko postara..

//move all non-indexed//

select 'alter table '||t.owner||'.'||t.table_name|| 'move tablespace table_small;'  
from dba_tables t 
where t.tablespace_name='USERS' 
and t.table_name not in 
(select i.table_name from dba_indexes i where t.owner=i.owner and i.table_name=t.table_name);

//move all indexed//

select 'alter index '||i.owner||'.'||i.index_name||' unusable;' 
,'alter table '||t.owner||'.'||t.table_name|| ' move tablespace table_small;'
,'alter index '||i.owner||'.'||i.index_name||' rebuild;'
from dba_tables t, dba_indexes i where 
t.tablespace_name='USERS' and 
t.table_name=i.table_nameand t.owner=i.owner;

 

 

Leave a Reply


Warning: Undefined variable $user_ID in /data/e/2/e2a12386-6c90-456e-9912-438742224460/papp.me.uk/sub/tomas/wp-content/themes/lighttheme/comments.php on line 54

You must be logged in to post a comment.