Skip to content

Instantly share code, notes, and snippets.

@ReeMii
Created October 24, 2013 11:07
Show Gist options
  • Save ReeMii/7135232 to your computer and use it in GitHub Desktop.
Save ReeMii/7135232 to your computer and use it in GitHub Desktop.
get table relations
SELECT
constraint_schema as db,
CONCAT( table_name, '.', column_name, ' -> ', referenced_table_name, '.', referenced_column_name ) AS relationship
FROM
information_schema.key_column_usage
WHERE
referenced_table_name = 'TableName'
ORDER BY
constraint_schema, table_name, column_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment