From: Michael Brusser <michael@synchronicity.com>
To: dudsen <dudsen@koen.dk>
To: pgsql-admin@postgresql.org
Subject: Re: GRANT on all tables?
Date: Thu, 24 Apr 2003 11:43:26 -0400
Message-ID: <DEEIJKLFNJGBEMBLBAHCOEHDDBAA.michael@synchronicity.com> (raw)
In-Reply-To: <1050499026.680723@kalvebod.groenjord.dk>
You can try something like this, just modify it for the language you use:
set permission "SELECT" ;# update, all...
lappend sql "SELECT 'grant $permission on ' || relname || ' to \"$username\"
;' from pg_class "
lappend sql "WHERE relname not like 'pg_%' and relkind in ('r','v');"
Now you have sql which, when executed, dynamically generates sql
for granting desired permission for all tables and views.
You may add 's' to the last clause to include sequences, if needed.
You can run something like that in a single shot;
for example you can execute sql with output redirected to a temp file,
then include this file, or maybe come up with something more fancy to
avoid using files at all.
Hope it helps.
Mike.
> -----Original Message-----
> From: pgsql-admin-owner@postgresql.org
> [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of dudsen
> Sent: Wednesday, April 16, 2003 9:17 AM
> To: pgsql-admin@postgresql.org
> Subject: [ADMIN] GRANT on all tables?
>
>
> How do I GRANT an user privileges for all tables in an database with one
> command, as it is now i need to specify the name of each table.
> I want to write something like
> GRANT SELECT,INSERT ON mydatabase TO user; this doesn't work but
> are there a
> way of getting someting similar to work?
>
> --
> Daniel Udsen
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.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: michael@synchronicity.com, dudsen@koen.dk
Subject: Re: GRANT on all tables?
In-Reply-To: <DEEIJKLFNJGBEMBLBAHCOEHDDBAA.michael@synchronicity.com>
References: <1050499026.680723@kalvebod.groenjord.dk> <DEEIJKLFNJGBEMBLBAHCOEHDDBAA.michael@synchronicity.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