码迷,mamicode.com
首页 > 其他好文 > 详细

Query Index In a table

时间:2016-01-12 15:14:17      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

查看一个表的Index info

1,Script1

--query index in a table

select o.name,o.object_id,
    i.name as indexname,i.index_id,i.type_desc,
    ic.column_id,ic.is_included_column,ic.key_ordinal as Index_column_Ordinal,
    c.name as columnname
from sys.objects o
inner join sys.indexes i on o.object_id=i.object_id
inner join sys.index_columns ic on i.object_id=ic.object_id and i.index_id=ic.index_id
inner join sys.columns c on o.object_id=c.object_id  and ic.column_id=c.column_id
where o.name=FactProductorder by i.index_id

 

2,Script2

--query index in a table include filter index

select o.name,o.object_id,
    i.name as indexname,i.index_id,i.type_desc,
    ic.column_id,ic.is_included_column,ic.key_ordinal as Index_column_Ordinal,
    c.name as columnname,
    i.has_filter,i.filter_definition
from sys.objects o
inner join sys.indexes i on o.object_id=i.object_id
inner join sys.index_columns ic on i.object_id=ic.object_id and i.index_id=ic.index_id
inner join sys.columns c on o.object_id=c.object_id  and ic.column_id=c.column_id
where o.name=factProduct
order by i.index_id

 

Query Index In a table

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/5124012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!