Skip to content

Instantly share code, notes, and snippets.

@Lkledu
Last active July 30, 2019 12:23
Show Gist options
  • Save Lkledu/478ed9daa5c8e2f082b378e9922418a5 to your computer and use it in GitHub Desktop.
Save Lkledu/478ed9daa5c8e2f082b378e9922418a5 to your computer and use it in GitHub Desktop.
Retorna uma coluna com suas foreign keys <POSTGRESQL>
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>' AND
REFERENCED_COLUMN_NAME = '<column>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment