How can I query all GRANTS granted to an object in postgres?
For example I have table \"mytable\":
GRANT SELECT, INSERT ON mytable TO user1
GRANT UPD
If you really want one line per user, you can group by grantee (require PG9+ for string_agg)
SELECT grantee, string_agg(privilege_type, ', ') AS privileges
FROM information_schema.role_table_grants
WHERE table_name='mytable'
GROUP BY grantee;
This should output something like :
grantee | privileges
---------+----------------
user1 | INSERT, SELECT
user2 | UPDATE
(2 rows)