Granting Privleges on All Tables in One Comand?

Started by Adamabout 20 years ago5 messagesgeneral
Jump to latest
#1Adam
adam@spatialsystems.org

Is it possible to 'GRANT SELECT ON ALL TABLES TO User' in 1 command ?

I saw the question in 2003 and wonder if it's still true.

#2Bruce Momjian
bruce@momjian.us
In reply to: Adam (#1)
Re: Granting Privleges on All Tables in One Comand?

Adam wrote:

Is it possible to 'GRANT SELECT ON ALL TABLES TO User' in 1 command ?

I saw the question in 2003 and wonder if it's still true.

Still true, but on the TODO list:

o %Allow GRANT/REVOKE permissions to be applied to all schema objects
with one command

The proposed syntax is:
GRANT SELECT ON ALL TABLES IN public TO phpuser;
GRANT SELECT ON NEW TABLES IN public TO phpuser;

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: Granting Privleges on All Tables in One Comand?

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Adam wrote:

Is it possible to 'GRANT SELECT ON ALL TABLES TO User' in 1 command ?

I saw the question in 2003 and wonder if it's still true.

Still true, but on the TODO list:

Also, you can do it today by making a plpgsql function that iterates
through all the tables and does GRANTs. There are examples in the
mailing list archives. (The TODO item would probably have been done
by now if it weren't so easy to work around it.)

regards, tom lane

#4Joshua D. Drake
jd@commandprompt.com
In reply to: Adam (#1)
Re: Granting Privleges on All Tables in One Comand?

Adam wrote:

Is it possible to 'GRANT SELECT ON ALL TABLES TO User' in 1 command ?

No it is not. But you easily loop it with a one line script :)

I saw the question in 2003 and wonder if it's still true.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

--
The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: PLphp, PLperl - http://www.commandprompt.com/

#5Larry Rosenman
ler@lerctr.org
In reply to: Joshua D. Drake (#4)
Re: Granting Privleges on All Tables in One Comand?

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Adam wrote:

Is it possible to 'GRANT SELECT ON ALL TABLES TO User' in 1 command
?

I saw the question in 2003 and wonder if it's still true.

Still true, but on the TODO list:

Also, you can do it today by making a plpgsql function that iterates
through all the tables and does GRANTs. There are examples in the
mailing list archives. (The TODO item would probably have been done
by now if it weren't so easy to work around it.)

One example:

http://www.archonet.com/pgdocs/grant-all.html

--
Larry Rosenman
Database Support Engineer

PERVASIVE SOFTWARE. INC.
12365B RIATA TRACE PKWY
3015
AUSTIN TX 78727-6531

Tel: 512.231.6173
Fax: 512.231.6597
Email: Larry.Rosenman@pervasive.com
Web: www.pervasive.com