Created
November 26, 2018 01:59
-
-
Save t18n/bdb6c4aa07c60029912e4ad587e196b5 to your computer and use it in GitHub Desktop.
Show all constraints PostgresSQL.md
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 conrelid::regclass AS table_from | |
, conname | |
, pg_get_constraintdef(c.oid) | |
FROM pg_constraint c | |
JOIN pg_namespace n ON n.oid = c.connamespace | |
WHERE contype IN ('f', 'p ') | |
AND n.nspname = 'public' -- your schema here | |
ORDER BY conrelid::regclass::text, contype DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment