Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 1002 Bytes

grant-privileges-to-a-user-or-role.md

File metadata and controls

29 lines (18 loc) · 1002 Bytes

Grant Privileges To A User Or Role

Category: Postgres

For security reasons you should create a user with the least amount of privilege required for your application to connect to a Postgres database.

This TIL shows how to grant privileges to a user or role which restricts rights so that it cannot not be used to create new users, database objects, or drop tables, schemas, or databases.

Grant privileges to a user

Grant use of the default schema public for the user orbiks_dbusr:

GRANT USAGE ON SCHEMA public TO orbiks_dbusr;

Grant access to all tables in the schema public for the user orbiks_dbusr:

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

Grant specific permissions on a set of tables for the user orbiks_dbusr:

GRANT SELECT, INSERT ON orders, events, alerts IN SCHEMA public TO orbiks_dbusr;

See PostgreSQL GRANT for more details.