2011-11-03 60 views

回答

3

可以使用information_schema.key_column_usage表:

SELECT table_name, column_name, referenced_table_name, referenced_column_name 
FROM information_schema.key_column_usage 
WHERE referenced_table_name IS NOT NULL 

如果您需要限制您查询到特定的数据库,您可以添加AND table_schema = 'yourdatabase'

+0

非常感谢webbi,...我也看到它可以使用SHOW CREATE TABLE table_name – boctulus

+2

是的,你可以使用'SHOW CREATE TABLE',但是如果你想要使用表/代码中的列。 – webbiedave