I have Azure postgresql single server database which I need to give read permission to a newly created user.
CREATE USER "test@hostName" PASSWORD 'XXXX'; GRANT CONNECT ON DATABASE "test" TO "test@hostName";
ALTER DEFAULT PRIVILEGES FOR USER pgadmin IN SCHEMA public GRANT SELECT ON TABLES TO "test@hostName" ;
SELECT * FROM information_schema.role_table_grants WHERE grantee = 'test@hostName';
But when this user executes a select query Permission Denied message appear and not allowed to select. Any help is appreciated.
To assign permission to newly created user in Azure PostgreSQL follow below procedure:
--create a new database.
CREATE DATABASE newdb;
--create a new user.
CREATE USER newuser PASSWORD '<StrongPassword!>';
--grant new user to connect databse.
GRANT CONNECT ON DATABASE newdb TO newuser;
public
schema to the new user with following command.--to switch the database with current login
\c test
--Grant select on table with ath following schema
GRANT SELECT ON ALL TABLES IN SCHEMA schemaname TO newuser;
select * from tablename;