Created
September 14, 2021 14:34
-
-
Save portothree/8dddc9bc7b77d5b2f3ce50c7e8ad6f19 to your computer and use it in GitHub Desktop.
Retrieve Postgres constraints with `pg_catalog.pg_constraint`
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 rel.relname = 'table_name'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment