oracle如何转移表的表空间

本篇内容主要讲解“oracle如何转移表的表空间”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“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;

oracle如何转移表的表空间  oracle 第1张

生成指定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如何转移表的表空间  oracle 第2张

到此,相信大家对“oracle如何转移表的表空间”有了更深的了解,不妨来实际操作一番吧!这里是蜗牛博客网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接