Search code examples
sqlpostgresqlsql-grant

Query grants for a table in postgres


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

Solution

  • I already found it:

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