Created
April 11, 2018 11:40
-
-
Save marlomgirardi/bc8d72da2a55e4ed3d03d60eb502edb8 to your computer and use it in GitHub Desktop.
MySQL Utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ------------------ | |
-- FIND FK TO A TABLE | |
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>'; | |
-- ------------------- | |
-- FIND FK TO A COLUMN | |
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_COLUMN_NAME = '<column>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment