Re: Grant privs on entire database, not table-by-table-by-table

From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: James Long <pgsql-novice(at)museum(dot)rain(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Grant privs on entire database, not table-by-table-by-table
Date: 2011-11-22 05:17:31
Message-ID: CAJKUy5hRDWNz5XK+miQGCh4je8Z_FJOpg8AUK7B4io4xdZOQ6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, Nov 21, 2011 at 10:57 PM, James Long
<pgsql-novice(at)museum(dot)rain(dot)com> wrote:
>
> buddy_db=# grant all on database buddy_db to buddy;
> GRANT
> buddy_db=#
>

this is not for granting privileges on all objects in the database but
for granting all types of privileges on the database to this user.
types of privileges for a database are: CREATE | CONNECT | TEMPORARY |
TEMP

what you're looking for is not possible in 8.3, the ability to grant
privileges to several objects in 1 command was introduced in 9.0 and
even there is limited to one kind of object in one schema at a time.

a workaround in 8.3 would be to read the catalogs and generate a
script, below sql would generate such a script for tables you should
try to make your own for other objects:
"""
copy
(select 'GRANT ALL ON TABLE ' || table_schema || '.' || table_name ||
' TO buddy; '
from information_schema.tables
where table_schema not in ('pg_catalog', 'information_schema')
and table_type = 'BASE TABLE'
) to '/tmp/grants.sql';
"""
--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Hery Fanomezantsoa 2011-11-22 13:40:36 A CallableStatement was excecuted with an invalid number of parameters
Previous Message James Long 2011-11-22 03:57:03 Grant privs on entire database, not table-by-table-by-table