From: Oliver Elphick <olly@lfix.co.uk>
To: Zuoxin.Wang@kp.org
Cc: agold@cbamedia.com
Cc: pgsql-admin@postgresql.org
Subject: Re: GRANT ALL PRIVILEGES ON DATABASE
Date: Wed, 17 Aug 2005 17:08:23 +0100
Message-ID: <1124294903.12095.141.camel@linda> (raw)
In-Reply-To: <OFF2C30C25.B80FFBF2-ON88257060.00535B8D@KP.ORG>
References: <OFF2C30C25.B80FFBF2-ON88257060.00535B8D@KP.ORG>
On Wed, 2005-08-17 at 08:14 -0700, Zuoxin.Wang@kp.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@lfix.co.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: olly@lfix.co.uk, Zuoxin.Wang@kp.org, agold@cbamedia.com
Subject: Re: GRANT ALL PRIVILEGES ON DATABASE
In-Reply-To: <1124294903.12095.141.camel@linda>
References: <OFF2C30C25.B80FFBF2-ON88257060.00535B8D@KP.ORG> <1124294903.12095.141.camel@linda>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox