Check Postgres access for a user

后端 未结 3 859
青春惊慌失措
青春惊慌失措 2021-01-31 14:01

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 accessibilit

相关标签:
3条回答
  • 2021-01-31 14:09

    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;
    
    0 讨论(0)
  • 2021-01-31 14:26

    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'
    
    0 讨论(0)
  • 2021-01-31 14:28

    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');
    
    0 讨论(0)
提交回复
热议问题