GRANT
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
Functions and Volumes are schema child objects. Grant CREATE FUNCTION and CREATE VOLUME on the parent schema, and grant the remaining privileges on the specific object. The object suffix in Function and Volume privilege names is optional, but the full names are recommended; SHOW GRANTS displays the full names.
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 FUNCTION, CREATE VOLUME, and ALL |
schemaObjectPrivileges | Yes (when granting Schema object privileges) | Privileges on Schema objects, such as ALTER, DROP, SELECT, INSERT, READ METADATA, ALL |
functionPrivileges | Yes (when granting Function privileges) | Function privileges such as USE FUNCTION, ALTER FUNCTION, and DROP FUNCTION |
volumePrivileges | Yes (when granting Volume privileges) | Volume privileges such as READ VOLUME, WRITE VOLUME, and DROP VOLUME |
workspace_name | Yes (when granting workspace privileges) | Workspace name |
workspace_object_name | Yes (when granting workspace object privileges) | Name of the workspace object (Role, Schema, or VCluster) |
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 role
my_rolequery privilege on a specified dynamic table:Grant role all privileges on a dynamic table:
-
Grant user
testerthe roletest_readonly_role: -
Grant user
testerquery privilege on a specified table, with the ability to re-grant: -
Grant a role the privileges required to create and use a Function:
-
Grant a role the privileges required to create and access a Volume:
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.
