如何查询数据库的主键约束schema?
2007-07-18 23:07 爱车龟速兔 阅读(606) 评论(0) 编辑 收藏 举报select
c.CONSTRAINT_NAME,c.TABLE_NAME,c.COLUMN_NAME
from
INFORMATION_SCHEMA.TABLE_CONSTRAINTS t
join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE c
on t.CONSTRAINT_NAME=c.CONSTRAINT_NAME
where CONSTRAINT_TYPE='PRIMARY KEY'
c.CONSTRAINT_NAME,c.TABLE_NAME,c.COLUMN_NAME
from
INFORMATION_SCHEMA.TABLE_CONSTRAINTS t
join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE c
on t.CONSTRAINT_NAME=c.CONSTRAINT_NAME
where CONSTRAINT_TYPE='PRIMARY KEY'
要获取数据库构架, 需要从专门的数据库中获取.