查询一个库的外键关系

SELECT
CONCAT(table_name, '.', column_name) AS 'foreign key',
CONCAT(referenced_table_name, '.', referenced_column_name) AS 'references'
FROM information_schema.key_column_usage 
WHERE table_schema='数据库名称' AND referenced_table_name IS NOT NULL;

你可能感兴趣的:(mysql,外键)