Oracle表移動表空間

leon830216發表於2018-03-14

在oracle中有時需要把表移動到其他表空間中,下面是移動的步驟。
首先,使用下面的命令移動:
alter table table_name move tablespace tablespace_name;
然後,如果有索引的話必須重建索引:
alter index index_name rebuild tablespace tablespace_name;

需要注意的地方是:
1、若表中需要同時移動lob相關欄位的資料,就必需用如下的含有特殊引數據的語句來完成。

alter table tb_name move tablespace tbs_name lob (col_lob1,col_lob2) store as(tablesapce tbs_name);

如果表特別多,可以生產一個執行的指令碼。
select 'alter index '||OWNER||'.'||index_NAME||' rebuild tablespace tablespace_name;' from dba_indexes where OWNER='USERS';
select 'alter table '||OWNER||'.'||TABLE_NAME||' move tablespace tablespace_name;' from dba_tables where OWNER='USERS';

EOF

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22558114/viewspace-2151860/,如需轉載,請註明出處,否則將追究法律責任。

相關文章