Goal Find all comments of columns of tables.
Notes The query excludes columns of system catalog tables.
Type General (Overview of some aspect of the database.)
License MIT License
Data Source system catalog only
SQL Query
SELECT n.nspname AS table_schema, 
c.relname AS table_name, 
a.attname AS column_name, 
CASE WHEN c.relkind='r' THEN 'BASE TABLE'
WHEN c.relkind='v' THEN 'VIEW'
WHEN c.relkind='m' THEN 'MATERIALIZED VIEW'
WHEN c.relkind='f' THEN 'FOREIGN TABLE'
WHEN c.relkind='p' THEN 'PARTITIONED TABLE'
END AS table_type,
d.description
FROM pg_description AS d INNER JOIN pg_class AS c
ON d.objoid=c.oid
INNER JOIN pg_attribute AS a
ON c.oid=a.attrelid AND d.objsubid=a.attnum
INNER JOIN pg_namespace AS n
ON n.oid=c.relnamespace INNER JOIN pg_authid AS au ON n.nspowner=au.oid
WHERE (n.nspname='public' OR au.rolname<>'postgres')
ORDER BY table_schema, table_name, a.attnum;

Collections

This query belongs to the following collections:

NameDescription
Find problems by overviewQueries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
Categories

This query is classified under the following categories:

NameDescription
CommentsQueries of this category provide information about comments to the database objects that have been registered in the system catalog.