Find MySQL Foreign Keys

January 9th, 2014

Sometimes you need a quick way to find out what foreign key is blocking your action.

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 referenced_table_name IS NOT NULL;

http://www.conandalton.net/2008/09/list-foreign-key-constraints-in-oracle.html

WordPress - Entries (RSS) and Comments (RSS) - © 2011 Ben Dauphinee