pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: Randall Perry <rgp@systame.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: How do I grant access to entire database at
Date: Sun, 18 Jul 2004 21:41:51 +0100
Message-ID: <1090183311.25749.98.camel@linda> (raw)
In-Reply-To: <BD204D49.7DA1B%rgp@systame.com>
References: <BD204D49.7DA1B%rgp@systame.com>

On Sun, 2004-07-18 at 20:52, Randall Perry wrote:
> This is a pain. Couldn't we gave something simple like
> GRANT ALL ON database.* TO JOE;
> 
> Which would grant full access to all objects in the database to JOE for all
> time?

You can do it like this in psql:

\a
\t
\o /tmp/grant.sql
SELECT      'GRANT ALL ON ' || n.nspname || '.' || c.relname ||
            ' TO joe;'
  FROM      pg_catalog.pg_class AS c 
            LEFT JOIN pg_catalog.pg_namespace AS n
                 ON n.oid = c.relnamespace
  WHERE     c.relkind IN ('r','v','S') AND
            n.nspname NOT IN ('pg_catalog', 'pg_toast') AND
            pg_catalog.pg_table_is_visible(c.oid)
  ORDER BY  n.nspname, c.relname;
\o
\i /tmp/grant.sql


The above could be put in a script and run from a Unix command prompt.

(The SQL used above is adaated from that used by psql's \d command.)

-- 
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
                 ========================================
     "For God so loved the world, that he gave his only 
      begotten Son, that whosoever believeth in him should 
      not perish, but have everlasting life."     John 3:16 




view thread (11+ messages)  latest in thread

Message-ID: <1090183311.25749.98.camel@linda>
Permalink:  ../1090183311.25749.98.camel@linda/
Also on:    postgresql.org/message-id/1090183311.25749.98.camel@linda

 · 

reply

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, rgp@systame.com
  Subject: Re: How do I grant access to entire database at
  In-Reply-To: <1090183311.25749.98.camel@linda>
  References: <BD204D49.7DA1B%rgp@systame.com> <1090183311.25749.98.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