pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to avoid having to run the GRANT command for newly added tables?
3+ messages / 2 participants
[nested] [flat]

* How to avoid having to run the GRANT command for newly added tables?
@ 2022-11-23 20:06  Siddharth Jain <siddhsql@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Siddharth Jain @ 2022-11-23 20:06 UTC (permalink / raw)
  To: pgsql-general

Hello - I have a Postgres 14 server. I created a database and then gave all
privileges to tables in the database to a user as shown below:
grant connect on database testdb to test_user;
GRANT all ON ALL TABLES IN SCHEMA "public" TO test_user;
I now verified that test_user is able to access an EXISTING table:
select count(*) from test;
 count
-------
     0
(1 row)
However when the postgres superuser creates a NEW table:
create table test2( id integer primary key);
CREATE TABLE
the test_user is not able to access it:
select count(*) from test2;
ERROR:  permission denied for table test2
This is really inconvenient for me and I'd like to avoid having to run the
GRANT command again and again after creating new tables. Is there any way
to accomplish what I want? Thanks.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to avoid having to run the GRANT command for newly added tables?
@ 2022-11-23 20:07  Christophe Pettus <xof@thebuild.com>
  parent: Siddharth Jain <siddhsql@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Christophe Pettus @ 2022-11-23 20:07 UTC (permalink / raw)
  To: Siddharth Jain <siddhsql@gmail.com>; +Cc: pgsql-general



> On Nov 23, 2022, at 12:06, Siddharth Jain <siddhsql@gmail.com> wrote:
> Is there any way to accomplish what I want? Thanks.

There is:

	https://www.postgresql.org/docs/current/sql-alterdefaultprivileges.html





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to avoid having to run the GRANT command for newly added tables?
@ 2022-11-23 20:13  Siddharth Jain <siddhsql@gmail.com>
  parent: Christophe Pettus <xof@thebuild.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Siddharth Jain @ 2022-11-23 20:13 UTC (permalink / raw)
  To: Christophe Pettus <xof@thebuild.com>; +Cc: pgsql-general

Thanks Christophe. it works.

On Wed, Nov 23, 2022 at 12:08 PM Christophe Pettus <xof@thebuild.com> wrote:

>
>
> > On Nov 23, 2022, at 12:06, Siddharth Jain <siddhsql@gmail.com> wrote:
> > Is there any way to accomplish what I want? Thanks.
>
> There is:
>
>
> https://www.postgresql.org/docs/current/sql-alterdefaultprivileges.html
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-11-23 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 20:06 How to avoid having to run the GRANT command for newly added tables? Siddharth Jain <siddhsql@gmail.com>
2022-11-23 20:07 ` Christophe Pettus <xof@thebuild.com>
2022-11-23 20:13   ` Siddharth Jain <siddhsql@gmail.com>

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