Home:ALL Converter>Getting role comments in PostgreSQL by query

Getting role comments in PostgreSQL by query

Ask Time:2018-03-02T20:37:37         Author:Davide Toller

Json Formatter

Postgresql allows adding comments to roles and users. For example I've added a comment to role "myuser" by using this SQL command:

COMMENT ON ROLE myuser IS 'User comment...';

My question is: If I want to use a SQL-command to get all users along with their respective comment - how would I do this? What would be the appropriate query for this?

Author:Davide Toller,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49069303/getting-role-comments-in-postgresql-by-query
Łukasz Kamiński :

You need to use built-in function shobj_description(object_oid, catalog_name)\n\nSELECT *, shobj_description(oid, 'pg_authid') AS comment\n FROM pg_roles;\n",
2018-03-02T13:00:03
yy