Created
July 11, 2020 15:42
-
-
Save jonmathews/611b77634a4d96b5220406b6a2424880 to your computer and use it in GitHub Desktop.
Get all column description/comments from Postgres
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
WITH tables | |
AS (SELECT oid, | |
relname AS table | |
FROM pg_class), | |
columns | |
AS (SELECT ordinal_position AS objsubid, | |
table_name AS table, | |
column_name AS column | |
FROM information_schema.columns) | |
SELECT t.table, | |
c.COLUMN, | |
d.description | |
FROM pg_catalog.pg_description d | |
LEFT JOIN tables t | |
ON d.objoid = t.oid | |
LEFT JOIN columns c | |
ON d.objsubid = c.objsubid | |
AND t.table = c.table | |
WHERE d.objsubid > 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment