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 B52A9D1B170 for ; Sun, 18 Jul 2004 17:42:02 -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 68944-06 for ; Sun, 18 Jul 2004 20:41:59 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 8CE73D1B1D5 for ; Sun, 18 Jul 2004 17:41:55 -0300 (ADT) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1BmITs-0002kz-0W; Sun, 18 Jul 2004 21:41:56 +0100 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.34) id 1BmITn-0006tm-66; Sun, 18 Jul 2004 21:41:51 +0100 Subject: Re: How do I grant access to entire database at From: Oliver Elphick Reply-To: olly@lfix.co.uk To: Randall Perry Cc: pgsql-admin@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: LFIX Limited Message-Id: <1090183311.25749.98.camel@linda> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sun, 18 Jul 2004 21:41:51 +0100 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/209 X-Sequence-Number: 14277 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