I would like to give an user all the permissions on a database without making it an admin. The reason why I want to do that is that at the moment DEV and PROD are different DBs on the same cluster so I don't want a user to be able to change production objects but it must be able to change objects on DEV.
I tried:
grant ALL on database MY_DB to group MY_GROUP;
but it doesn't seem to give any permission.
Then I tried:
grant all privileges on schema MY_SCHEMA to group MY_GROUP;
and it seems to give me permission to create objects but not to query\delete objects on that schema that belong to other users
I could go on by giving USAGE permission to the user on MY_SCHEMA but then it would complain about not having permissions on the table ...
So I guess my question is: is there any easy way of giving all the permissions to a user on a DB?
I'm working on PostgreSQL 8.1.23.
The user needs access to the database, obviously:
And (at least) the
USAGE
privilege on the schema:Then, all permissions for all tables (requires Postgres 9.0 or later):
And don't forget sequences (if any):
For older versions you could use the "Grant Wizard" of pgAdmin III (the default GUI).
More:
But really, you should upgrade to a current version.
I did the following to add a role 'eSumit' on PostgreSQL 9.4.15 database and provide all permission to this role :
Also checked the pg_table enteries via :
select * from pg_roles;
Database queries snapshot :
In PostgreSQL 9.0+ you would do the following:
If you want to enable this for newly created relations too, then set the default permissions:
However, seeing that you use 8.1 you have to code it yourself:
This will set the privileges on all relations: tables, views, indexes, sequences, etc. If you want to restrict that, filter on
pg_class.relkind
. See the pg_class docs for details.You should run this function as superuser and as regular as your application requires. An option would be to package this in a cron job that executes every day or every hour.