原表空间:USEROADB
新表空间:OAUSER
1.检查表空间有什么内容(包括表、索引、分区等)
SELECT segment_name,tablespace_name,segment_type FROM dba_segments WHERE tablespace_name='USEROADB';
2.将LONG类型字段转为CLOB
?
select 'alter table '||table_name||' modify ('||column_name||' clob);' from ?user_tab_columns where data_type='LONG'
?
3.将原表空间USEROADB中包含LOB类型字段的表移到新表空间OAUSER
SELECT 'alter table '|| b.table_name ||' move '|| 'tablespace USEROADB lob('|| b.column_name ||') store as (tablespace OAUSER);'?
FROM dba_segments a,dba_lobs b?
WHERE a.segment_name = b.segment_name AND a.tablespace_name = 'USEROADB'?
4.将普通表移至新表空间OAUSER
select 'alter table '|| table_name ||' ?move tablespace OAUSER;' ?from user_all_tables where ?tablespace_name ='USEROADB';
5.将索引移至新表空间OAUSER
select 'alter index '|| index_name ||' rebuild tablespace OAUSER;' from user_indexes where ?tablespace_name ='USEROADB';