首页 > 技术文章 > 监控索引是否使用

tianmingt 2015-04-21 17:04 原文

为方面的查看建立的索引是否被使用,可以使用如下方法,示例如下

ha_wxzj 用户下批量查 监控索引语句
select 'alter index ' || index_name || ' monitoring usage;' as "index_statement"
from user_indexes

将查出来的语句全部复制出来 在command 中执行

--查询索引监控状态及是否使用 used 表示是否使用 monitoring 表示是否监控
select * from v$object_usage;

--重命名索引 加引号不是 '''' 而是双引号 "",如果是有索引名的直接用名字即可,下面是没有索引名字的
alter index "BIN$KlUan6J2SbSmL8iyNg4gBg==$0" rename to empnp_PK;

--删除约束
alter table emp drop constraint "BIN$vCU/6synShGquH31PIj3ww==$0";

--重命名主键约束
alter table jack rename constraint pk_id to pk_jack_id;

推荐阅读