oracle 迁移表空间
--迁移默认表空间
--FRADATA_01:要迁移到的目标表空间
--XXX_1300:要迁移的表名
--执行查询后,将语句复制到命令窗口执行
select 'alter table '|| table_name ||' modify default attributes tablespace FRADATA_01'
from dba_tables where table_name = 'XXX_1300';
---迁移已有表空间
--XXX_1300:要迁移的表名
--FRADATA_01:要迁移到的目标表空间
begin
for x in (select partition_name from dba_tab_partitions where table_name = 'XXX_1300')
loop
execute immediate 'alter table XXX_1300 move partition '|| x.partition_name ||' tablespace FRADATA_01';
end loop;
end;
---索引
--XXX_1300:要迁移的表名
--IND_XXX_1300:要迁移的索引
--FRADATA_01:要迁移到的目标表空间
begin
for x in (select partition_name from dba_tab_partitions where table_name = 'XXX_1300')
loop
execute immediate 'ALTER INDEX IND_XXX_1300 REBUILD PARTITION '||x.partition_name || ' tablespace FRADATA_01';
end loop;
end;