skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search