Skip to content

Instantly share code, notes, and snippets.

@jonmathews
jonmathews / Postgres column descriptions
Created July 11, 2020 15:42
Get all column description/comments from Postgres
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,
@jonmathews
jonmathews / Postgres column metadata
Created July 15, 2020 07:11
Find all public column metadata in Postgres DB
select * from information_schema.columns where table_schema in (select schema_name from information_schema.schemata where schema_owner <> 'postgres')
@jonmathews
jonmathews / Postgres column metadata
Created July 15, 2020 07:13
Get column metadata from Postgres
SELECT c.relname AS table, d.description
FROM pg_catalog.pg_description d
LEFT JOIN pg_class c
ON d.objoid = c.oid
WHERE d.objsubid = 0
AND c.relname is not null