Does PostgreSQL allow multiple grantees in GRANT commands?

Posted on

Question :

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?

Answer :

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

Read 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;

Leave a Reply

Your email address will not be published. Required fields are marked *