postgresql - view schema privileges

后端 未结 9 1988
再見小時候
再見小時候 2020-12-24 12:17

Is there a query I can run to show currently assigned privileges on a particular schema?

i.e. privileges that were assigned like so:

GRANT USAGE ON S         


        
9条回答
  •  执笔经年
    2020-12-24 12:48

    I know this post is old but I made another query based on the different answers to have one that is short and easy to use afterward :

    select
        nspname as schema_name
        , r.rolname as role_name
        , pg_catalog.has_schema_privilege(r.rolname, nspname, 'CREATE') as create_grant
        , pg_catalog.has_schema_privilege(r.rolname, nspname, 'USAGE') as usage_grant
    from pg_namespace pn,pg_catalog.pg_roles r
    where array_to_string(nspacl,',') like '%'||r.rolname||'%' 
        and nspowner > 1 
    

    I keep thinking one day I will make a query to have all rights in only one view... One day. ;)

提交回复
热议问题