数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

查看数据库中有无多余的索引SQL


发布日期:2022年10月14日
 
查看数据库中有无多余的索引SQL

查看数据库中有无多余的索引即一个索引的字段为另一个索引的前几个字段如index的定义为test(filedfiled)index的定义为test(filedfiledfiled)则认为index是多余的

column redundant_index format a

column sufficient_index format a

select /*+ ordered */

oname||||nname redundant_index

oname||||nname sufficient_index

from

(

select

obj#

bo#

count(*) cols

max(decode(pos# intcol#)) leadcol#

from

sysicol$

group by

obj#

bo#

) ic

sysicol$ ic

sysind$ i

sysobj$ n

sysobj$ n

sysuser$ o

sysuser$ o

where

icobj# != icobj# and

icbo# = icbo# and

icpos# = and

icintcol# = icleadcol# and

iobj# = icobj# and

bitand(iproperty ) = and

ls * (ls + ) / =

( select

sum(xcpos#)

from

sysicol$ xc

sysicol$ xc

where

xcobj# = icobj# and

xcobj# = icobj# and

xcpos# = xcpos# and

xcintcol# = xcintcol#

) and

nobj# = icobj# and

nobj# = icobj# and

ouser# = nowner# and

ouser# = nowner#

上一篇:使用OTL调用Oracle的存储函数

下一篇:Oracle发布新版BerkeleyDB嵌入式数据库