Re: GRANT on all tables? - Mailing list pgsql-admin

From Michael Brusser
Subject Re: GRANT on all tables?
Date
Msg-id DEEIJKLFNJGBEMBLBAHCOEHDDBAA.michael@synchronicity.com
Whole thread Raw
In response to GRANT on all tables?  (dudsen <dudsen@koen.dk>)
List pgsql-admin
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
>


pgsql-admin by date:

Previous
From: Adam Witney
Date:
Subject: Re: Creating schema for multiple tables/fields/indices.
Next
From: "Victor Yegorov"
Date:
Subject: Re: Creating schema for multiple tables/fields/indices.