Hi
Naveen Kumar Kakarla (Quadrant Resource) •,
Welcome to Microsoft Q&A forum.
As I understand, you want Query to give all permissions to a user on a PostgreSQL database.
How to create database users in Azure Database for PostgreSQL Flexible Server?
- Get the connection information and admin user name. You need the full server name and admin sign-in credentials to connect to your database server. You can easily find the server name and sign-in information from the server Overview page or the Properties page in the Azure portal.
- Use the admin account and password to connect to your database server. Use your preferred client tool, such as pgAdmin or psql.
- Edit and run the following SQL code. Replace the placeholder value
<db_user> with your intended new user name and placeholder value <newdb> with your own database name. Replace the placeholder password with your own strong password.
This SQL code below creates a new database, then it creates a new user in the PostgreSQL instance and grants connect privilege to the new database for that user.
CREATE DATABASE <newdb>;
CREATE USER <db_user> PASSWORD '<StrongPassword!>';
GRANT CONNECT ON DATABASE <newdb> TO <db_user>;
- Using an admin account, you may need to grant other privileges to secure the objects in the database. Refer to the PostgreSQL documentation for further details on database roles and privileges. For example:
GRANT ALL PRIVILEGES ON DATABASE <newdb> TO <db_user>;
If a user creates a table "role", the table belongs to that user. If another user needs access to the table, you must grant privileges to the other user on the table level.
For example:
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO <db_user>;
- Sign in to your server, specifying the designated database, using the new username and password. This example shows the psql command line. With this command, you're prompted for the password for the user name. Replace your own server name, database name, and user name.
psql --host=mydemoserver.postgres.database.azure.com --port=5432 --username=db_user --dbname=newdb
Reference Link: https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-create-users#how-to-create-database-users-in-azure-database-for-postgresql
Let us know if you face any issue in execution.
Thanks