重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
在oracle中有時需要把表移動到其他表空間中,下面是移動的步驟。
首先,使用下面的命令移動:
alter table table_name move tablespace tablespace_name;
然后,如果有索引的話必須重建索引:
alter index index_name rebuild tablespace tablespace_name;
創新互聯建站主營武陟網站建設的網絡公司,主營網站建設方案,成都App定制開發,武陟h5小程序定制開發搭建,武陟網站營銷推廣歡迎武陟等地區企業咨詢
需要注意的地方是:
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';