Getting list of table comments in PostgreSQL

All comments are stored in pg_description

To get the comments on a table, you need to join it to pg_class

As an alternative you can also use the function obj_description() to retrieve this information:

SELECT obj_description(oid)
FROM pg_class
WHERE relkind = 'r'

Edit

In psql you can simply use the \d+ command to show all tables including their comments. Or use the \dd command to show all comments in the system

Leave a Comment