ORACLE中表、索引的表空间的批量更改方法

ORACLE中表、索引的表空间的批量更改方法

1、查询 当前用户下 的所有表
select 'alter table  '|| table_name ||'  move tablespace tablespacename ;'  from user_all_tables;
select 'ALTER TABLE '|| table_name ||' MOVE TABLESPACE tablespacename;' from user_tables;

 

2、查询当前用户下的所有索引
select 'alter index '|| index_name ||' rebuild tablespace tablespacename;' from user_indexes;

3、在当前用户下将查询结果批处理执行即可!

查看所有的unusable索引
SELECT *
FROM   user_indexes
WHERE  status NOT IN ('VALID', 'N/A')
ORDER BY index_name;

-- Description  : Displays unusable indexes for the specified schema or all schemas.
-- Requirements : Access to the DBA views.
-- Call Syntax  : @unusable_indexes (schema-name or all)

SET VERIFY OFF

SELECT owner,
       index_name
FROM   dba_indexes
WHERE  owner = DECODE(UPPER('&1'), 'ALL', owner, UPPER('&1'))
AND    status NOT IN ('VALID', 'N/A')
ORDER BY owner, index_name;

 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值