--结合sys.indexes和sys.index_columns,sys.objects,sys.columns查询索引所属的表或视图的信息
select
o.name as 表名,
i.name as 索引名,
c.name as 列名,
i.type_desc as 类型描述,
is_primary_key as 主键约束,
is_unique_constraint as 唯一约束,
is_disabled as 禁用
from sys.objects o
inner join sys.indexes i on i.object_id=o.object_id
inner join sys.index_columns ic on ic.index_id=i.index_id and ic.object_id=i.object_id
inner join sys.columns c on ic.column_id=c.column_id and ic.object_id=c.object_id
where o.name='CSEMPL_1'
根据表名称找索引及对应列名
最新推荐文章于 2023-02-03 15:56:53 发布