How to grant select to all tables in PostgreSQL

In this article, we will see how to grant select to all tables in PostgreSQL. We can grant select privilege in PostgreSQL by using grant command.

Syntax to grant select to all tables in PostgreSQL:

GRANT SELECT ON ALL TABLES IN SCHEMA schema_name to user_name/role_name;

1. Grant select on tables to public schema in the database ‘r2schools’.

First, we have to switch to the database where we want to grant SELECT privilege on public schema.

\c r2schools

Now, run the below command to grant select privilege to user ‘james’ on the database r2schools.

grant select on all tables in schema public to james;

How to grant select to all tables in PostgreSQL

2. Now, grant execute permissions all functions in the schema public to user james with following command.

grant execute on all functions in schema public to james;