oracle如何转移表的表空间

50次阅读
没有评论

共计 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 网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-13发表,共计1253字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)