您的位置:首页 > 其它

移动表空间内数据两种方式

2016-12-12 11:08 253 查看
1,手动迁移对象
select 'alter table '||owner||'.'||segment_name||' move tablespace '||'TBS_NEW;'
from dba_segments
where tablespace_name='TBS_OLD' and segment_type='TABLE' and owner='U1';

select 'alter index '||owner||'.'||segment_name||' rebuild tablespace '||'TBS_NEW;'
from dba_segments where tablespace_name='TBS_OLD' and segment_type='INDEX' and owner='U1';

select 'alter table '||t1.owner||'.'||t2.TABLE_NAME||' move lob ('||t2.COLUMN_NAME||') store as (tablespace '||'TBS_NEW);'
from dba_segments t1, dba_lobs t2
where t1.owner=t2.OWNER and t1.tablespace_name=t2.TABLESPACE_NAME and t1.segment_name=t2.SEGMENT_NAME
and t1.tablespace_name='TBS_OLD' and t1.segment_type='LOBSEGMENT' and t1.owner='U1';
2,整体迁移表空间
alter tablespace TBS_1 offline;
os mv '/ora01/oradata/tbs_1_data01.dbf' TO '/ora02/oradata/tbs_1_data01.dbf'
alter tablespace TBS_1 RENAME DATAFILE '/ora01/oradata/tbs_1_data01.dbf' TO '/ora02/oradata/tbs_1_data01.dbf';
alter tablespace TBS_1 online;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐