Posted on 2012-05-01 16:37
墨…… 阅读(1302)
评论(0) 编辑 收藏 引用
一:查询出所有表的键
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME='you tableName'
二:查询出所有的外键
select * from
(
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME='Data_Product'
) tableTemp
where CONSTRAINT_NAME like 'FK%'
另外表的类型有 'C', 'F', 'PK', 'UQ', 'D' 可以按键需要来修改
转载自http://www.diybl.com/course/7_databases/mysql/Mysqljs/20090415/165077.html