How to grant permissions on database to user?

Mykhailo Levandovskiy 20 Reputation points
2025-05-26T09:21:23.8966667+00:00

Hi,

I have a Flexible Postgesql server with several databases, i.e. db01.

And I want to grant INSERT,UPDATE,DELETE privileges for all tables in public schema on database db01 to user myuser01.

I connected as psqladmin user and tried to run these commands:

\c db01
grant insert on all tables in schema public to myuser01;
WARNING:  no privileges were granted for "table01"

grant all privileges on database db01 to myuser01

alter schema public owner to myuser01;
ERROR:  must be able to SET ROLE "myuser01"


So my question is: how to give user write permissions for all tables in database?

Thanks.

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. PratikLad 1,825 Reputation points Microsoft External Staff Moderator
    2025-05-29T08:33:09.5133333+00:00

    Hi Mykhailo Levandovskiy

    no privileges were granted for "table01"

    It usually means that the user running the GRANT command (in your case, psqladmin) doesn't actually own the table. In PostgreSQL, only the table owner or a superuser can grant permissions on that table.

    For example, when you run:

    
    GRANT INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO myuser01;
    
    

    it will only apply to tables owned by the user you're currently connected as. If other users own some of the tables, those won't be affected by this command.

    To grant permissions on those tables, you'll need to either:

    • Run the command as the user who owns the tables, or
    • Use a superuser account to apply the privileges.
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.