I have a Postgres DB with multiple databases, whose schemas are owned by individual service users. Now, I want to create a user which can access all those databases/schemas with atleast SELECT permissions. Is there any effective way of assigning permission to that new user?
Apparently, what I understand is I will have to login with those individual service users (owner) one by one and have to grant permissions to the new user. This is an overly complicated and time consuming process. Please advice if my understanding is not correct and if it is correct, is there any better way to do it?
Thanks in advance.
2
Answers
Create one role that has the correct (default) permissions. When you create new roles for new users, GRANT this default role to the new role.
Check the manual for details.
Two options:
-By database:
GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO role_name;
-By script
https://dba.stackexchange.com/questions/95867/grant-usage-on-all-schemas-in-a-database
Greetings, Alejandro