script to find what are the users having CREATE privilege's on AWS Redshift database:
SELECT u.usename AS username,
nsp.nspname AS schema_name,
has_schema_privilege(u.usename, nsp.nspname, 'CREATE') AS has_create_privilege
FROM pg_user u
CROSS JOIN pg_namespace nsp
WHERE nsp.nspname NOT LIKE 'pg_%' AND nsp.nspname not in ('information_schema','public') and u.usename not in('admin')
AND has_schema_privilege(u.usename, nsp.nspname, 'CREATE') = true
ORDER BY u.usename, nsp.nspname;
No comments:
Post a Comment