7

Looking at the PostgreSQL docs it seems that the GRANT command only grants to a single user or role. In fact it doesn't seem to be PostgreSQL alone.

Isn't possible to do something like GRANT SELECT UPDATE ON atable TO mary, bob, sue?

It looks like a major omission to me, or is there some reason, historical or practical for it?

1
  • I guess because a role can be associated with many users. Commented Aug 8, 2014 at 11:50

1 Answer 1

9

Yes it does, but that will turn into a maintenance headache down the road.

Read http://en.wikipedia.org/wiki/Role-based_access_control for justification for assigning rights to roles over individual users.

Simply create a role and assign users to it, and then grant privileges to that role.

create role some_group;

grant some_group to mary, bob, sue;

grant select, update on a_table to some_group;
2
  • Does this sequence in the syntax[, ...] as in TO { [ GROUP ] rolename | PUBLIC } mean comma separated instances of the symbols to the left of it?
    – vfclists
    Commented Aug 26, 2014 at 22:24
  • 1
    @vfclists yes. This would be valid: grant select on a_table to group1, group2, group3 Commented Aug 26, 2014 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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