一般情况下,下面语句基本可以涵盖所有的数据对象了:
select segment_type, segment_name, partition_name,
case segment_type
when 'TABLE' then 'alter table ' || owner || '.' || segment_name || ' move tablespace dbs_temp;',
when 'INDEX' then 'alter index ' || owner || '.' || segment_name || ' rebuild tablespace dbs_temp;',
when 'INDEX PARTITION' then 'alter index ' || owner || '.' || segment_name || ' rebuild tablespace dbs_temp;',
when 'TABLE PARTITION' then 'alter table ' || owner || '.' || segment_name || ' move partition ' || partition_name || 'tablespace dbs_temp;' sqltext
from dba_segments
where tablespace_name = 'FUND_TABLE'
and segment_type not like 'LOB%';
下面是迁移lob字段的
from dba_lobs
where tablespace_name = 'FUND_TABLE';
4、删除清空后的表空间;
drop tablespace dbs_old including contents and datafiles;
下面步骤简单了,就不一一列举。
5、如果对表空间名称有要求,则使用原来的表空间名再次创建一个合适大小的表空间。
6、将目标表空间中的数据再迁移回新建的最终的表空间。