Last active
August 29, 2015 14:21
-
-
Save sebastianwebber/77f685a60ea3ec79ff30 to your computer and use it in GitHub Desktop.
List USER permissions by table on PostgreSQL
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
| -- Tested on PostgreSQL 9.4 | |
| -- More details on http://www.postgresql.org/docs/9.4/static/functions-info.html | |
| -- and http://www.postgresql.org/docs/9.4/static/view-pg-tables.html | |
| -- and http://www.postgresql.org/docs/9.4/static/view-pg-roles.html | |
| SELECT | |
| schemaname, | |
| tablename, | |
| rolname, | |
| has_table_privilege(rolname, tablename, 'SELECT') as can_select, | |
| has_table_privilege(rolname, tablename, 'UPDATE') as can_update, | |
| has_table_privilege(rolname, tablename, 'DELETE') as can_delete, | |
| has_table_privilege(rolname, tablename, 'INSERT') as can_insert | |
| FROM pg_tables, pg_roles | |
| WHERE schemaname NOT IN ('information_schema', 'pg_catalog'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment