oracle 修索引改空间_oracle修改表和索引的表空间

表做空间迁移时,使用如下语句:

例1:alter table tb_name move tablespace tbs_name;

索引表空间做迁移,使用如下语句:

例2:alter index index_name rebuild tablespace tbs_name;

对于含有lob字段的表,在建立时,oracle会自动为lob字段建立两个单独的segment,一个用来存放数据,另一个用来存放索引,并且它们都会存储在对应表指定的表空间中,而例1:只能移动非lob字段以外的数据,所以在对含有lob字段的表进行空间迁移,需要使用如下语句:

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

项目实例:

表空间迁移

select 'alter table' ||table_name|| 'move tablespace tbs_name;' table_name from dba_tables where wner='%***%' and table_name like '%***%'

带lob字段

select 'alter table' ||table_name|| 'move lob('||index_name||') store as (tablespace tbs_name);' from dba_indexes where wner='%***%' and index_name like '%***%'

索引表空间

select 'alter index' ||index_name|| 'rebuild tablespace tbs_name;' index_name from dba_indexes where wner='%***%' and table_name like '%***%'

以上在oracle 的SQL*Plus Worksheet中运行,将得出的运行结果再运行一次即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值