oracle 表空间迁移,移动表空间

需求,将当前用户下所有的表以及数据移动到新的表空间里

总共5步:

1:创建新的表空间

create tablespace ylpw datafile '/u01/oracle/oradata/ora10g/ylpw.dbf' size 150m autoextend on next 20m permanent online; 2:生成移动表到新的表空间的脚本

select 'alter table '||table_name||' move tablespace ylpw  ;' from user_tables;

3:生成移动索引到新表空间的脚本 select 'alter index '||index_name||' rebuild tablespace ylpw  ;' from user_indexes  where index_type !='LOB';

4:生成移动大字段索引到新的表空间的索引 select 'alter table '||t.TABLE_NAME||' move lob('||wm_concat(t.COLUMN_NAME)||') store as (tablespace ylpw);' from user_tab_columns t  where t.DATA_TYPE='CLOB'and t.TABLE_NAME in (select table_name from user_indexes  where index_type ='LOB') group by t.TABLE_NAME;

5:检查索引是否已经生效

select t.index_name,t.table_owner,t.status from user_indexes t;

 

下面给出该步骤的一个示例:

1:创建新的表空间

2:alter table T_TEAMWORK move tablespace ylpw  ;

3:alter index PK_T_UNIONPRODUCT rebuild tablespace ylpw  ;

4:alter table T_PRODUCT move lob(DESCRIPTION,OFFICIAL,INTRODUCTION) store as (tablespace ylpw);

5:

   

posted on 2012-11-22 15:47  站在云端  阅读(619)  评论(0编辑  收藏  举报

导航