In today’s article, we will learn how to create a role with SELECT permission and add a newly created user to this role.
For example, a user named Faruk was created below and a role with only select permission was created in the public schema.
1 2 3 | CREATE USER faruk with login password '1'; CREATE ROLE selectpermission; GRANT SELECT ON ALL TABLES IN SCHEMA public TO selectpermission; |
Authorization has been given to Faruk user for the select permission role.
1 | GRANT selectpermission TO faruk; |
Let’s perform a select on the relevant database.
Let’s check whether the user Faruk can perform an INSERT operation.
As seen above, an access denied error is returned.
This indicates that the operation we performed is correct.