共計 1253 個字符,預計需要花費 4 分鐘才能閱讀完成。
本篇內容主要講解“oracle 如何轉移表的表空間”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓丸趣 TV 小編來帶大家學習“oracle 如何轉移表的表空間”吧!
oracle 中,可利用“alter table”語句轉移表的表空間,該語句可修改表的數據,與“move tablespace”配合使用就可移動表的表空間,語法為“alter table 表名 move tablespace 新的表空間”。
本教程操作環境:Windows10 系統、Oracle 11g 版、Dell G3 電腦。
oracle 怎么轉移表的表空間
轉移表的表空間語法如下:
將表 table_name 移動到新的 new_tbsp 表空間
alter table table_name move tablespace new_tbsp;
生成指定 tbsp_name 表空間下的【所有表】生成移動 new_tbsp 表空間 SQL 語句
select alter table || table_name|| move tablespace new_tbsp; from user_tables where tablespace_name = tbsp_name
擴展:轉移不同的表空間
移動【索引】所在表空間:
如將索引 index_name 移動到新的 new_tbsp 表空間(LOB 數據類型的字段需按如下第 3 類處理)
alter index index_name rebuild tablespace new_tbsp;
– 生成指定 user_name 用戶下的【所有索引】生成移動 new_tbsp 表空間 SQL 語句
select alter index ||index_name|| rebuild tablespace new_tbsp; from user_indexes where table_owner = user_name
移動【二進制流字段】數據存儲表空間,如將表 table_name 中的二進制流字段 col_name 移動到 new_tbsp 表空間
alter table table_name move tablespace new_tbsp lob (col_name) store as (tablespace new_tbsp);
– 生成指定表 table_name 中為 CLOB 類型的字段的移動到 new_tbsp 表空間 SQL 語句
select alter table || table_name|| move tablespace new_tbsp lob (|| column_name|| ) store as (tablespace new_tbsp); from user_tab_columns
where data_type= CLOB and table_name= table_name
到此,相信大家對“oracle 如何轉移表的表空間”有了更深的了解,不妨來實際操作一番吧!這里是丸趣 TV 網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!