Created
April 12, 2024 04:18
-
-
Save ppazos/a833415be92afdf1e594dd17e39d0cf7 to your computer and use it in GitHub Desktop.
Gets all the FKs that points to a given table
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
SELECT | |
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME | |
FROM | |
INFORMATION_SCHEMA.KEY_COLUMN_USAGE | |
WHERE | |
REFERENCED_TABLE_SCHEMA = (SELECT DATABASE()) AND | |
REFERENCED_TABLE_NAME = '$TABLE_NAME' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment