role/user creation

how to create a role that only allows read write access to a user to all existing tables and future tables. Also role should not have table creation or drop table access. Just read from the tables and write to the tables. 
  • post-author-pic
    Keith T
    10-22-2018

    Hi Harsh,


    I believe something like this should work, but I haven't tested it myself (don't currently have a PostgreSQL database running). This will give the proper permissions to the `readonly` role for current and future tables in the `public` schema:

    GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
    ALTER DEFAULT PRIVILEGES IN SCHEMA public
    GRANT SELECT ON TABLES TO readonly;


    Hopefully, that helps (and I'm not completely wrong).

Looking For Team Training?

Learn More