X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C26F452BFF for ; Wed, 17 Aug 2005 13:08:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40735-01 for ; Wed, 17 Aug 2005 16:08:37 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 464E152BF3 for ; Wed, 17 Aug 2005 13:08:36 -0300 (ADT) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) id 1E5QSu-000ObI-BG; Wed, 17 Aug 2005 16:08:32 +0000 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.50) id 1E5QSl-0006Eb-JH; Wed, 17 Aug 2005 17:08:23 +0100 Subject: Re: GRANT ALL PRIVILEGES ON DATABASE From: Oliver Elphick Reply-To: olly@lfix.co.uk To: Zuoxin.Wang@kp.org Cc: agold@cbamedia.com, pgsql-admin@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: LFIX Limited Date: Wed, 17 Aug 2005 17:08:23 +0100 Message-Id: <1124294903.12095.141.camel@linda> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-LFIX-MailScanner-SpamCheck: not spam, SpamAssassin (score=-5.899, required 5, autolearn=not spam, ALL_TRUSTED -3.30, BAYES_00 -2.60) X-LFIX-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/221 X-Sequence-Number: 18540 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