notes/postgres/descriptions.sql
Paul Trowbridge 2a6f1c5dcf redis
2020-01-12 21:28:28 -05:00

28 lines
767 B
SQL

SELECT
c.relname table_name,
td.description table_description,
n.nspname schema_name,
a.attname As column_name,
cd.description column_description
FROM
pg_class As c
INNER JOIN pg_attribute As a ON
c.oid = a.attrelid
LEFT JOIN pg_namespace n ON
n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON
t.oid = c.reltablespace
LEFT JOIN pg_description As cd ON
cd.objoid = c.oid
AND cd.objsubid = a.attnum
LEFT JOIN pg_description As td ON
td.objoid = c.oid
AND td.objsubid = 0
WHERE
c.relkind IN('r', 'v')
--AND a.attname = 'd07txn'
AND cd.description like '%Transaction Number%'
ORDER BY
n.nspname,
c.relname,
a.attname