mysql获取外键, 根据数据库名和表名获取表所对应的所有外键
SELECT ii.`COLUMN_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS ii WHERE ii.`CONSTRAINT_SCHEMA`='xius' AND ii.`TABLE_NAME`='comment_user' AND ii.`REFERENCED_COLUMN_NAME` != 'null';
xius: 数据库名
comment_user: 表名
SELECT ii.`COLUMN_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS ii WHERE ii.`CONSTRAINT_SCHEMA`='xius' AND ii.`TABLE_NAME`='comment_user' AND ii.`REFERENCED_COLUMN_NAME` != 'null';
xius: 数据库名
comment_user: 表名