Created
May 11, 2020 18:56
-
-
Save mattlockyer/84e031ea2b3fa1942d55a22076ea4b94 to your computer and use it in GitHub Desktop.
Postgres - get constraints from table
This file contains hidden or 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 con.* | |
FROM pg_catalog.pg_constraint con | |
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid | |
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace | |
WHERE | |
nsp.nspname = '<schema name>' | |
AND rel.relname = '<table name>'; | |
/* from: https://dba.stackexchange.com/a/214877/187757 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment