Oracle的表空间迁移_数据

移植表空间

alter table TABLE_NAME move tablespace TABLESPACENAME

将数据从一个表空间移植到另一个表空间

select 'alter table ' ||table_name || ' move tablespace systemportal;' from user_all_tables where tablespace_name='OA'; 

当导完数据后需要重新建立索引 否则报错

select index_name from user_indexes where status = 'UNUSABLE' 查询失效索引
alter index 索引名 rebuild; 重新建立索引

如果失效索引太多 那么可以执行以下过程

 
declare
vc_index_name varchar2(100); --索引名称
cursor index_cur is
select index_name from user_indexes where status = 'UNUSABLE'; --获取当前登录用户所有不可用的索引
begin
open index_cur;
fetch index_cur into vc_index_name;
loop
exit when not index_cur%found;
--dbms_output.put_line(vc_index_name);
execute immediate 'alter index '||vc_index_name||' rebuild';
fetch index_cur into vc_index_name;
end loop;
close index_cur;
end;