pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marsha Ramsey <msramsey22@yahoo.com>
To: Oliver Elphick <olly@lfix.co.uk>
To: pgsql-admin@postgresql.org
Subject: Re: Grant SELECT on all tables of a database
Date: Tue, 29 May 2007 13:03:44 -0700 (PDT)
Message-ID: <27253.98855.qm@web31810.mail.mud.yahoo.com> (raw)
In-Reply-To: <1180468302.15764.31.camel@linda.lfix.co.uk>

This does the JOB...thank you very much!!!! 

Oliver Elphick <olly@lfix.co.uk> wrote: On Tue, 2007-05-29 at 10:21 -0700, Marsha Ramsey wrote:
> Hello all,
> 
> How do I GRANT SELECT to all my tables at once?  I have over 1026
> tables in this database...

I don't think there is any direct SQL command to do it. But try this:

psql -d your_database
        \t
        \a
        \o /tmp/sqlscript
        SELECT 'GRANT SELECT ON '  || schemaname || '.' || tablename ||
        ' TO PUBLIC ;'
          FROM pg_tables
          WHERE tableowner = CURRENT_USER;
        \o
        \i /tmp/sqlscript
        
-- 
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


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


       
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.

view thread (3+ messages)

Message-ID: <27253.98855.qm@web31810.mail.mud.yahoo.com>
Permalink:  ../27253.98855.qm@web31810.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/27253.98855.qm@web31810.mail.mud.yahoo.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: msramsey22@yahoo.com, olly@lfix.co.uk
  Subject: Re: Grant SELECT on all tables of a database
  In-Reply-To: <27253.98855.qm@web31810.mail.mud.yahoo.com>

* 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