Function Description
Grants specified privileges to a role or user, enabling fine-grained access control for workspace resources.
Workspace User and Role Permission Management Syntax
Privilege Type Description
Parameter Description
| Parameter | Required | Description |
|---|---|---|
workspacePrivileges | Yes (when granting workspace privileges) | Workspace-level privileges, such as CREATE SCHEMA, CREATE VCLUSTER |
workspaceObjectPrivileges | Yes (when granting workspace object privileges) | Privileges on workspace objects, such as ALTER, DROP, READ METADATA, ALL [PRIVILEGES] |
schemaPrivileges | Yes (when granting Schema privileges) | Schema-level privileges, such as CREATE TABLE, CREATE VIEW, CREATE MATERIALIZED VIEW, ALL |
schemaObjectPrivileges | Yes (when granting Schema object privileges) | Privileges on Schema objects, such as ALTER, DROP, SELECT, INSERT, READ METADATA, ALL |
workspace_name | Yes (when granting workspace privileges) | Workspace name |
workspace_object_name | Yes (when granting workspace object privileges) | Name of the workspace object (Schema, VCluster, Function, etc.) |
schema_name | Yes (when granting Schema privileges) | Schema name |
schema_object_name | Yes (when granting Schema object privileges) | Full object name in the format schema_name.object_name |
role_name | Yes (when granting to a role) | Name of the role being granted privileges |
user_name | Yes (when granting to a user) | Name of the user being granted privileges |
WITH GRANT OPTION | No | Allows the grantee to re-grant this privilege to other users |
Usage Examples
-
Grant role
simple_rolethe privilege to create VCLUSTERs in the workspace: -
Grant role
simple_rolethe privilege to alter the VCLUSTER nameddefault: -
Grant role
simple_rolethe privilege to create tables and views in thepublicSchema: -
Grant role
my_rolequery and modification privileges on a specified table: -
Grant role
my_rolequery privilege on a specified view: -
Grant role
my_rolequery privilege on a specified materialized view: -
Grant user
testerthe roletest_readonly_role: -
Grant user
testerquery privilege on a specified table, with the ability to re-grant:
Successful execution returns an empty result set; no error message means the grant was successful. You can verify the grant result using SHOW GRANTS TO ROLE role_name or SHOW GRANTS TO USER user_name.
Notes
- Executing this command requires the
workspace_adminorsecurity_adminrole, or havingWITH GRANT OPTIONpermission on the target object. - It is recommended to manage permissions through roles (
GRANT ROLE) for easier batch granting and unified revocation. - Follow the principle of least privilege, granting only the minimum permissions required to complete the work.
- Use
WITH GRANT OPTIONwith caution, as the grantee may propagate permissions to other users.
Instance Role Granting
Instance Roles can be used to grant cross-workspace global permissions. Grant targets include users or other roles.
