sql 查看表的所有键,索引信息
select i.name,[Type]=case when i.is_unique=1 and is_primary_key=1 then '主键' when i.is_unique=1 and is_primary_key=0 then '唯一键' else '索引' end,TypeRemark=i.type_desc from sys.indexes i where i.[object_id]=object_id('表名') and i.name is not null union select f.name,'外键',OBJECT_NAME(f.referenced_object_id) from sys.foreign_keys f where f.parent_object_id=object_id('表名') union select d.name,'默认值',d.[definition] collate Latin1_General_CI_AS_KS_WS from sys.default_constraints d where d.parent_object_id=object_id('表名') union select c.name,'约束值',c.definition collate Latin1_General_CI_AS_KS_WS from sys.check_constraints c where c.parent_object_id=object_id('表名')
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步