Query grants for a table in postgres

markus picture markus · Sep 7, 2011 · Viewed 107.7k times · Source

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 UPDATE ON mytable TO user2 

I need somthing which gives me:

user1: SELECT, INSERT
user2: UPDATE

Answer

markus picture markus · Sep 7, 2011

I already found it:

SELECT grantee, privilege_type 
FROM information_schema.role_table_grants 
WHERE table_name='mytable'