Created
February 2, 2021 09:41
-
-
Save ycku/659bbf366dc1e516f167a4abbce16c06 to your computer and use it in GitHub Desktop.
PostgreSQL show comments of all column in the specified table by query
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
-- https://www.postgresql.org/docs/current/infoschema-columns.html | |
SELECT | |
cols.column_name, | |
( | |
SELECT | |
pg_catalog.col_description(c.oid, cols.ordinal_position::int) | |
FROM pg_catalog.pg_class c | |
WHERE | |
c.oid = ((cols.table_schema||'.'||cols.table_name)::regclass::oid) AND | |
c.relname = cols.table_name | |
) as column_comment | |
FROM information_schema.columns cols | |
WHERE | |
cols.table_schema = 'YOUR_SCHEMA' AND | |
cols.table_name = 'YOUR_TABLE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment