Re: Grant on several tables at once

From: sforteln(at)fhcrc(dot)org
To: MaRcElO PeReIrA <gandalf_mp(at)yahoo(dot)com(dot)br>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Grant on several tables at once
Date: 2003-08-01 21:13:43
Message-ID: 1059772423.3f2ad807a4e41@webmail.fhcrc.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Marcelo,

Something like this should work to grant rights on all non system tables

psql -t -A -U $DBOWNER -c "select tablename from pg_tables where tablename not
like 'pg_%'" $DB_NAME | xargs -i ./psql -t -A -U $DBOWNER -c "grant ALL on {} to
$USER" $DB_NAME

Quoting MaRcElO PeReIrA <gandalf_mp(at)yahoo(dot)com(dot)br>:

> Hello All,
>
> I have a database that contain 72 tables. How can I grant "SELECT" on
> all those 72 tables to a user, at once?
>
> I use to do:
>
> # grant select on table1 to marcelo;
> # grant select on table2 to marcelo;
> # ...
> # grant select on table72 to marcelo;
>
> but it is a lot of tables... I would like to do this at once!
>
> Thanks in advance and
> Best Regards,
>
> Marcelo
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message maillist 2003-08-01 22:07:10 Re: fyi regarding error I've seen posted before
Previous Message Rajesh Kumar Mallah 2003-08-01 20:15:20 Re: Grant on several tables at once