0

I currently have a group role. This group role is called team. Team currently has the permission to create databases.

I have one user that is a member of team. But that user is unable to create a database. May I ask if anyone has some insight why the user is not inheriting permissions from the group?

1 Answer 1

0

CREATEDB is not a permission, but an attribute of the role. It is not inherited, much like the password, which is also an attribute of the role.

You will have to use ALTER TABLE to set the CREATEDB attribute on the member role:

ALTER ROLE enduser CREATEDB;

Another option is that the end users use SET ROLE to become the role with CREATEDB. Then they can create a database:

SET ROLE dbcreaterole;
CREATE DATABASE newdb;
RESET ROLE;
6
  • Hi @Laurenz Albe, I've just starte to dabble into PostGres. I have a Sql server knowledge. May I ask for alittle more guidance. Not sure how Alter Table would assist me. Essentially two things I'm trying to achieve. Give any user part of team permissions to do anything as they please and anyone with team permission to create databases
    – Master
    Mar 8 at 15:46
  • I have added more ideas and details. Mar 8 at 15:51
  • Thank you. That gives permissions to the user. But what if I have 100 users. Is there a way to give it to group role and the user inherits from that since it's a member?
    – Master
    Mar 8 at 19:15
  • No, you cannot. You have to run 100 ALTER ROLE statements. I doubt that a setup where 100 users can create tables is really a great design. Mar 8 at 20:03
  • How do you suggest we handle permissions? For example, lets say an employee leaves and we want to revoke his credentials and deactivate his login. I don't think having just 1 user is sufficient as you would have to change the password and share it with the other 99 users
    – Master
    Mar 8 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.