Hologres is compatible with PostgreSQL and allows you to use the standard PostgreSQL authorization model. This topic describes how to grant and revoke permissions by using the standard PostgreSQL authorization model.
Grant permissions by using the standard PostgreSQL authorization model
After you connect a Hologres instance to a development tool, you can execute SQL statements to grant permissions on the instance to a user by using the standard PostgreSQL authorization model.
Grant permissions on the tables that will be created in the future
- This statement does not affect the permissions on existing objects.
- This statement can be used to grant the default permissions only on tables, schemas, functions, sequences, and types.
Revoke permissions by using the standard PostgreSQL authorization model
REVOKE SELECT ON TABLE tablename FROM "Alibaba Cloud account ID/Alibaba Cloud account name/RAM username"; -- If you want to revoke permissions from a RAM user, you must follow the formats that are used to specify RAM users in Hologres.
Query the permissions of a user
SELECT ROLNAME FROM pg_roles;
SELECT user_display_name(ROLNAME) FROM pg_roles;
Delete a user from a Hologres instance
- Delete a regular user
If your regular user has not created objects such as tables, views, or extensions, you can execute the following statement to delete the user from the Hologres instance. You can also delete the user in the HoloWeb console.
DROP USER "Alibaba Cloud account ID/Alibaba Cloud account name/RAM username";
- Delete an administrator
If your user has created objects such as tables, views, or extensions in the instance and is the administrator of these objects (especially in the standard PostgreSQL authorization model), you must transfer the objects to another user before you can delete the user. You can execute the following statements to delete the user:
-- Transfer the objects that are owned by User A to User B. REASSIGN OWNED BY "ID of User A" to "ID of User B"; -- Delete User A. DROP USER "ID of User A";
DROP USER "Alibaba Cloud account ID/Alibaba Cloud account name/RAM username";
The standard PostgreSQL authorization model divides permissions in a strict manner. Best practices for using the model are provided for your reference. You can use the model based on best practices and your business requirements. For more information, see Authorize roles based on PostgreSQL privileges.