Listing foreign-keys for a MySQL table

The following lets you find all foreign keys setup for a table (or entire database) in MySQL

SELECT    TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM   INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE   REFERENCED_TABLE_SCHEMA = '<database>' AND   REFERENCED_TABLE_NAME = '<table>';

Thanks to; https://stackoverflow.com/questions/201621/how-do-i-see-all-foreign-keys-to-a-table-or-column

Leave a Reply