由于開發人員把ess 項目下的大部分對象放到user 表空間中,用imp/exp 導入正式庫後,ess使用者的對象還是在users 表空間中.為了把ESS 的對象放到ess 預設的表空間ess中,我按如下幾步操作:
1、找出要修改表空間的對象:select * from dba_tables where owner='ESS' and tablespace_name = 'USERS';
select * from dba_INDEXES where table_owner='ESS' and tablespace_name = 'USERS';
2、生成批量修改的sql 語句select 'alter table ess.' || table_name || ' move tablespace ess;'
from dba_tables where wner='ESS' and tablespace_name = 'USERS';
select 'alter index ess.'||index_name||' rebuild online nologging tablespace ess;'
from DBA_indexes WHERE table_owner='ESS' and tablespace_name = 'USERS'
把生成sql語句導到 到ess_table.txt和ess_index.txt檔案中
3、因為我們這裡字段有clob類型,clob預設會建立索引,是以移動的時候要先移動clob字段所産生的索引。SELECT 'alter table ' ||t.table_name ||
' move tablespace ess lob (' || t.column_name ||
') store as(tablespace ess);' v_sql FROM user_lobs t
4、檢查users 表空間,看看ess 使用者的對象是不是少了