Created
January 20, 2022 13:56
-
-
Save os-ia/20aacb7b0b73f233d60e9acea5e40517 to your computer and use it in GitHub Desktop.
Get all constraints of a PostgreSQL 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 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>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment