Created
February 5, 2025 14:32
-
-
Save stand-sure/4755d4dd321632a9e65f8eb5e1d789ea to your computer and use it in GitHub Desktop.
Get user privileges postgres
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 u.usename AS username, | |
c.relname, | |
n.nspname, | |
pg_catalog.pg_table_is_visible(c.oid) as table_name, | |
has_table_privilege(c.oid, 'SELECT') as select_access, | |
has_table_privilege(c.oid, 'INSERT') as insert_access, | |
has_table_privilege(c.oid, 'UPDATE') as update_access, | |
has_table_privilege(c.oid, 'DELETE') as delete_access | |
FROM pg_catalog.pg_user u | |
CROSS JOIN pg_catalog.pg_class c | |
JOIN pg_namespace n on c.relnamespace = n.oid | |
WHERE c.relkind = 'r' -- Filter for only tables | |
and u.usename = 'analytics-reader' | |
ORDER BY username, table_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment