Re: GRANT ALL PRIVILEGES ON DATABASE

From: Zuoxin(dot)Wang(at)kp(dot)org
To: olly(at)lfix(dot)co(dot)uk
Cc: agold(at)cbamedia(dot)com, pgsql-admin(at)postgresql(dot)org
Subject: Re: GRANT ALL PRIVILEGES ON DATABASE
Date: 2005-08-17 16:17:28
Message-ID: OFEE21BB88.82D1F551-ON88257060.00594969@KP.ORG
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Which means everytime I create a new table or a new schema, I have to run
the script again, right?

Thanks.

Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
08/17/2005 09:08 AM
Please respond to olly


To: Zuoxin Wang/CA/KAIPERM(at)Kaiperm
cc: agold(at)cbamedia(dot)com, pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] GRANT ALL PRIVILEGES ON DATABASE

On Wed, 2005-08-17 at 08:14 -0700, Zuoxin(dot)Wang(at)kp(dot)org wrote:
>
> Could you tell us what is the best way to grant a user who can select
> all data from all tables, if I don't like to write a script which
> Andrew memtioned earlier.

Here's a quick way to generate a script and then run it, all from within
a psql session. This grants all privileges on all visible tables to a
user called that_user. It works by generating the commands and writing
them to a file, then executing that file as an SQL script:

$ psql -d my_database
\a
\t
\o /tmp/grant_privileges
select 'GRANT ALL PRIVILEGES ON ' || c.relname || ' TO that_user;' from
pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid
= c.relnamespace where relkind = 'r' AND n.nspname NOT IN ('pg_catalog',
'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid);
\o
\i /tmp/grant_privileges

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
Do you want to know God? http://www.lfix.co.uk/knowing_god.html

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Chris Hoover 2005-08-17 16:57:16 Re: vacuumdb -a -f
Previous Message Joshua D. Drake 2005-08-17 16:15:40 Re: vacuumdb -a -f