80

I have looked into the documentation for GRANT Found here and I was trying to see if there is a built-in function that can let me look at what level of accessibility I have in databases. Of course there is:

\dp and \dp mytablename

But this does not show what my account has access to. I would like to see ALL the tables I have access to. Can anyone tell me if there is a command that can check my level of access in Postgres (whether I have SELECT, INSERT, DELETE, UPDATE privileges)? And if so, what would that command be?

1
  • 2
    \du?, or query the grants table in information_schema directly.
    – Marc B
    Commented Nov 13, 2014 at 20:14

3 Answers 3

152

You could query the table_privileges table in the information schema:

SELECT table_catalog, table_schema, table_name, privilege_type
FROM   information_schema.table_privileges 
WHERE  grantee = 'MY_USER'
2
  • 9
    And you can only see rows that your db user is allowed to see. Commented Jul 9, 2019 at 18:59
  • It still doesn't tell me whether the use is admin or not?
    – N. Raj
    Commented Jan 23, 2023 at 7:54
8

For all users on a specific database, do the following:

# psql
\c your_database
select grantee, table_catalog, privilege_type, table_schema, table_name from information_schema.table_privileges order by grantee, table_schema, table_name;
5

Use this to list Grantee too and remove (PG_monitor and Public) for Postgres PaaS Azure.

SELECT grantee,table_catalog, table_schema, table_name, privilege_type
FROM   information_schema.table_privileges 
WHERE  grantee not in ('pg_monitor','PUBLIC');
1
  • only this command worked for me since it showed the role permissions..
    – t7e
    Commented Sep 15, 2023 at 8:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.