Permissions are used to control whether a user is allowed to access a database object (including schemas, tables, functions, and sequences) to perform operations such as adding, deleting, modifying, querying, and creating a database object.
Permission management in GaussDB(DWS) falls into three categories:
System permissions are also called user attributes, including SYSADMIN, CREATEDB, CREATEROLE, AUDITADMIN, and LOGIN.
They can be specified only by the CREATE ROLE or ALTER ROLE syntax. The SYSADMIN permission can be granted and revoked using GRANT ALL PRIVILEGE and REVOKE ALL PRIVILEGE, respectively. System permissions cannot be inherited by a user from a role, and cannot be granted using PUBLIC.
Permissions on a database object (table, view, column, database, function, schema, or tablespace) can be granted to a role or user. The GRANT command can be used to grant permissions to a user or role. These permissions granted are added to the existing ones.
Grant a role's or user's permissions to one or more roles or users. In this case, every role or user can be regarded as a set of one or more database permissions.
If WITH ADMIN OPTION is specified, the member can in turn grant permissions in the role to others, and revoke permissions in the role as well. If a role or user granted with certain permissions is changed or revoked, the permissions inherited from the role or user also change.
A database administrator can grant permissions to and revoke them from any role or user. Roles having CREATEROLE permission can grant or revoke membership in any role that is not an administrator.
GaussDB(DWS) implements a hierarchical permission management on databases, schemas, and data objects.

The permission management model of GaussDB(DWS) is a typical implementation of the role-based permission control (RBAC). It manages users, roles, and permissions through this model.
A role is a set of permissions.
To view all roles, query the system catalog PG_ROLES.
1 | SELECT * FROM PG_ROLES; |
For how to create, modify, and delete a role, see "CREATE ROLE/ALTER ROLE/DROP ROLE" in SQL Syntax Reference.
GaussDB(DWS) provides a group of preset roles. Their names start with gs_role_. These roles allow access to operations that require high permissions. You can grant these roles to other users or roles in the database for them to access or use specific information and functions. Exercise caution and ensure security when using preset roles.
The following table describes the permissions of preset roles.
Role |
Permission |
|---|---|
gs_role_signal_backend |
Invokes functions such as pg_cancel_backend, pg_terminate_backend, pg_terminate_query, pg_cancel_query, pgxc_terminate_query, and pgxc_cancel_query to cancel or terminate sessions, excluding those of the initial users. |
gs_role_read_all_stats |
Reads the system status view and uses various extension-related statistics, including information that is usually visible only to system administrators. For example: Resource management views:
Status information views:
|
gs_role_analyze_any |
A user with the system-level ANALYZE permission can skip the schema permission check and perform ANALYZE on all tables. |
gs_role_vacuum_any |
A user with the system-level VACUUM permission can skip the schema permission check and perform ANALYZE on all tables. |
gs_redaction_policy |
A user with the permission to create, modify, and delete data masking policies and can execute CREATE | ALTER | DROP REDACTION POLICY on all tables. Clusters of 9.1.0 and later versions support this function. |
Restrictions on using preset roles:
1 2 | GRANT gs_role_signal_backend TO user1; REVOKE gs_role_signal_backend FROM user1; |
A user who creates an object is the owner of this object. By default, Separation of Duties in GaussDB(DWS) is disabled after cluster installation. A database system administrator has the same permissions as object owners.
After an object is created, only the object owner or system administrator can query, modify, and delete the object, and grant permissions for the object to other users through GRANT by default. To enable a user to use an object, the object owner or administrator can run the GRANT or REVOKE command to grant permissions to or revoke permissions from the user or role.
1 2 | GRANT USAGE ON SCHEMA myschema TO u1; GRANT SELECT ON TABLE myschema.t1 to u1; |
REVOKE ALL PRIVILEGES ON myschema.t1 FROM u1;