grant read permissions postgres code example
Example 1: list all permissions on a table in postgres
SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_name='mytable'
Example 2: grant read only privileges postgres user
grant connect on database "mydatabase" to "user";
GRANT USAGE ON SCHEMA public TO "user";
GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO "user";
ALTER DEFAULT PRIVILEGES IN SCHEMA "public"
GRANT SELECT ON TABLES TO "user";