Configure roles and privileges for PostgreSQL PGVector users
You can manage user access permissions to databases in a PostgreSQL PGVector cluster using roles and privileges.
A role is a predefined set of privileges for specific operations. Assigning a role grants a user all privileges included in it at once. The role applies to all databases in the cluster.
A privilege is the right to perform operations on a specific database object: a schema, table, or function. Privileges are configured using SQL commands GRANT and REVOKE.
For each user, you can:
Configure user roles
Users of a PostgreSQL PGVector cluster can be assigned predefined roles. You cannot create custom roles.
Each user can be assigned multiple roles simultaneously. Assigning roles does not revoke user privileges that are configured using the GRANT and REVOKE commands.
You can assign roles when creating a user as well as change the list of roles for an existing user — grant additional roles or revoke previously granted ones.
Predefined roles
The composition of predefined roles in a PostgreSQL PGVector cluster cannot be changed. The superuser role is not provided.
Change the list of roles for a user
You can change the list of roles for an existing user: grant additional roles or revoke previously granted ones.
-
In the Control panel, in the top menu, click Products and select Cloud Databases.
-
Open the Active tab.
-
Open the cluster page → Users tab.
-
From the user menu, select Configure.
-
In the Roles field, click .
-
Change the list of roles for the user by checking or unchecking the checkboxes next to the roles.
-
To save the changes, click .
Configure user privileges
A database object (schema, table, function) is created by a specific user who becomes the owner of the object and has all rights to it by default. Other users, including the database owner, can be granted privileges on the object.
Starting with PostgreSQL version 15, the CREATE privilege on the public schema is not granted by default. Patterns for working with the public schema are described in the Usage Patterns section of the Schemas documentation for PostgreSQL.
Grant privileges
You can grant users privileges on database objects using the GRANT command; for details, see the GRANT instructions in the PostgreSQL documentation.
-
Connect to the database as the object owner.
-
Grant the user the required privileges using the
GRANTcommand.Example of granting read access (
SELECT) to the tabletableto useruser:GRANT SELECT ON table TO user;
Revoke privileges
You can revoke privileges from a user using the REVOKE command; for details, see the REVOKE instructions in the PostgreSQL documentation.
-
Connect to the database as the object owner.
-
Revoke privileges from the user using the
REVOKEcommand.Example of revoking a privilege from user
useron the schemaschema:REVOKE USAGE ON SCHEMA schema FROM user;
Example of creating a schema user with read-only permissions
You can create a user with access to a cluster database, a table in the default schema, and all tables in the schema.
All new tables will automatically be created with read-only access for this user.
-
Create a user
user. -
Grant access to user
userto the database. -
Connect to the database as the object owner.
-
Create schema
schemaand tabletable:CREATE SCHEMA schema;CREATE TABLE schema.table(i int);INSERT INTO schema.table(i) values(1); -
Grant privileges to user
user:GRANT USAGE ON SCHEMA schema TO user;GRANT SELECT ON ALL TABLES IN SCHEMA schema TO user;ALTER DEFAULT PRIVILEGES IN SCHEMA schema GRANT SELECT ON TABLES TO user;