Skip to content

Instantly share code, notes, and snippets.

@kany
Created March 4, 2013 18:51
Show Gist options
  • Save kany/5084473 to your computer and use it in GitHub Desktop.
Save kany/5084473 to your computer and use it in GitHub Desktop.
Find Foreign Keys - Mysql
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 AND
referenced_table_name = 'org_units';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment