How do I view grants on Redshift

前端 未结 6 974
半阙折子戏
半阙折子戏 2020-12-02 10:22

I\'d like to view grants on redshifts.

I found this view for postgres:

CREATE OR REPLACE VIEW view_all_grants AS 
SELECT 
  use.usename as subject, 
         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 11:24

    Here is another useful query to view grants on schema (usage, create) by user that I created based on the query above by @drtf:

    SELECT * 
    FROM 
        (
        SELECT 
            schemaname
            ,usename
            ,HAS_SCHEMA_PRIVILEGE(usrs.usename, schemaname, 'usage') AS usg
            ,HAS_SCHEMA_PRIVILEGE(usrs.usename, schemaname, 'create') AS crt
        FROM
            (
            SELECT distinct(schemaname) FROM pg_tables
            WHERE schemaname not in ('pg_internal')
            UNION
            SELECT distinct(schemaname) FROM pg_views
            WHERE schemaname not in ('pg_internal')
            ) AS objs
            ,(SELECT * FROM pg_user) AS usrs
        ORDER BY schemaname
        )
    WHERE (usg = true or crt = true)
    --and schemaname=''
    --and usename = '';
    

提交回复
热议问题