Change tablespace for INDEX/TABLE

本文介绍了在Oracle数据库中如何重建Normalcase类型的索引以及带有分区的索引,并提供了具体的SQL语句来帮助解决ORA-14086错误,即分区索引不能作为一个整体进行重建的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

1. Normal case

ALTER INDEX index_name rebuild TABLESPACE tablespace_name;

 

2. Index with partition

If TABLESPACE_NAME is null, which means the index has been partitioned.

 

SELECT TABLESPACE_NAME, a.* FROM user_indexes a;

 

if run below directly:

ALTER INDEX index_name rebuild TABLESPACE tablespace_name;

 

you will get error:

ORA-14086: a partitioned index may not be rebuilt as a whole

 

The solution is:

ALTER INDEX index_name rebuild PARTITION partition_name TABLESPACE tablespace_name;


Rebuild Index
----------------------------------------
select concat(concat('ALTER INDEX ',index_name),' REBUILD TABLESPACE tablespace_name ;') from dba_indexes where owner = ' owner' and tablespace_name is not null;

select concat(concat(concat('ALTER INDEX ',index_name),' REBUILD PARTITION '), concat(partition_name,' TABLESPACE tablespace_name;')) from DBA_IND_PARTITIONS where index_owner = 'owner';
----------------------------------------

Select all tablespace_name
----------------------------------------
select distinct tablespace_name from dba_tables where owner = '';
select distinct tablespace_name from dba_tab_partitions where table_owner = '';
select distinct tablespace_name from dba_tab_subpartitions where table_owner = '';

select distinct tablespace_name from dba_indexes where owner = '';
select distinct tablespace_name from dba_ind_partitions where index_owner = '';
select distinct tablespace_name from dba_ind_subpartitions where index_owner = '';
----------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值