database-indexes - 检查索引是否存在
问题描述
如果索引有 2 列或更多列,如何检查 SQL Server 上是否已有索引?我不想只检查名称我想按表按列检查
任何帮助,将不胜感激。
解决方案
Your question is a little vague, but if I understand correctly, you want to find indexes on all tables where the index has two or more columns:
select t.[name] TableName, i.[name] IndexName
from (
select object_id, Index_Id
from sys.index_columns
group by object_Id, Index_Id
having Count(*)>1
)x
join sys.indexes i on i.index_id=x.index_id and i.object_id=x.object_id
join sys.tables t on t.object_id=x.object_id and t.[type]='U'
order by Tablename, IndexName
推荐阅读
- windows - 如何在多显示器设置中让无边框子窗口重新缩放到当前屏幕?
- java - Jdbi 的声明式 API 性能对 Spring MVC Web 服务的影响
- neo4j - Neo4j 启动麻烦
- java - Java Stream API - 自定义无限源
- spring-batch - 如何在spring批处理中从多个相关数据库表中读取复杂数据
- sql - 无法解决 concat 操作中“SQL_Latin1_General_CP1_CI_AS”和“Indic_General_90_BIN”之间的排序规则冲突
- elasticsearch - 如何在聚合期间过滤掉某些值?
- r - 如何在 Shiny 中不同步地渲染两个 uiOutput?
- r - 使用 limma 从 vennDiagram 图中删除框框
- javascript - 将两个文本框值相加并在第三个文本框中获取等级字母