sqlserver 查询主外键索引常用语句

select *
from sys.key_constraints

exec sp_pkeys 'tablename'
exec sp_fkeys'tablename'

 

SELECT A.NAME AS 表名,B.NAME AS 主键名
FROM SYSOBJECTS A JOIN SYSOBJECTS B ON A.ID=B.PARENT_OBJ
AND A.XTYPE='U' AND B.XTYPE='PK'


SELECT TABLE_NAME,COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME='tablename'

上一篇:四:表介绍


下一篇:Java开发Hbase示例