Skip to content

Instantly share code, notes, and snippets.

@vivekragunathan
Created August 28, 2018 23:24
Show Gist options
  • Select an option

  • Save vivekragunathan/18379deeec3bb20c0f090c35a38cdd0d to your computer and use it in GitHub Desktop.

Select an option

Save vivekragunathan/18379deeec3bb20c0f090c35a38cdd0d to your computer and use it in GitHub Desktop.
Useful MySQL queries

List all tables foreign-keyed to a certain table <schema>.<TBL> and column <tbl_id>

SELECT *
FROM
  KEY_COLUMN_USAGE
WHERE
  REFERENCED_TABLE_NAME = '<TBL>'
  AND REFERENCED_COLUMN_NAME = '<tbl_id>'
  AND TABLE_SCHEMA = '<schema>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment