获取表的primary key
程序员文章站
2022-04-22 11:55:33
...
获取SQL Server表的primary key 无 SELECT cu.Column_NameFROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS t LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE cu ON t.CONSTRAINT_NAME = cu.CONSTRAINT_NAME AND cu.TABLE_NAME = t.TABLE_NAMELEFT JOIN IN
获取SQL Server表的primary keySELECT cu.Column_Name FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS t LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE cu ON t.CONSTRAINT_NAME = cu.CONSTRAINT_NAME AND cu.TABLE_NAME = t.TABLE_NAME LEFT JOIN INFORMATION_SCHEMA.COLUMNS c ON c.COLUMN_NAME = cu.COLUMN_NAME AND c.TABLE_NAME = cu.TABLE_NAME WHERE Constraint_Type = 'PRIMARY KEY ' AND cu.Table_Name = '
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论