Created
May 10, 2016 23:09
-
-
Save jdunck/3b2e262ba5417c1acca4289f382373c5 to your computer and use it in GitHub Desktop.
postgres permissions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select usename, nspname || '.' || relname as relation, | |
case relkind when 'r' then 'TABLE' when 'v' then 'VIEW' end as relation_type, | |
priv | |
from pg_class join pg_namespace on pg_namespace.oid = pg_class.relnamespace, | |
pg_user, | |
(values('SELECT', 1),('INSERT', 2),('UPDATE', 3),('DELETE', 4)) privs(priv, privorder) | |
where relkind in ('r', 'v') | |
and has_table_privilege(pg_user.usesysid, pg_class.oid, priv) | |
and not (nspname ~ '^pg_' or nspname = 'information_schema') | |
order by 2, 1, 3, privorder; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment