GRANT TO USER
Description
Grant specified permissions to a user or role to achieve fine-grained access control over workspace resources.
Syntax
Grant Object Permissions to a User
Grant a Role to a User
Privilege Type Definitions
Functions and Volumes are schema child objects. Grant creation privileges on the parent schema and grant use, alteration, or drop privileges on the specific object. The object suffix in Function and Volume privilege names is optional, but the full names above are recommended.
Parameter Description
| Parameter | Required | Description |
|---|---|---|
workspace_name | Yes (when granting workspace privileges) | Workspace name |
workspace_object_name | Yes (when granting workspace object privileges) | Name of the object under the workspace (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 |
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 |
user_name | Yes | The name of the user being granted permissions |
role_name | Yes (when granting a role) | Role name; supports custom roles and system preset roles |
WITH GRANT OPTION | No | Allows the grantee to re-grant these permissions to other users |
Usage Examples
-
Grant the role
test_readonly_roleto usertester: -
Grant user
testerthe permission to query tablesemantic_model_test.dim_customer: -
Grant user
testerthe permission to create tables under schemasemantic_model_test: -
Grant user
testerthe permission to create a VCluster in the workspace: -
Grant role
test_developer_rolethe permission to create views under schemasemantic_model_test: -
Grant user
testerthe permission to modify VClusterdefault, with the ability to re-grant: -
Grant user
testerpermission to invoke Functionsemantic_model_test.image_to_text: -
Grant user
testerread and write access to Volumesemantic_model_test.shared_files:
A successful command returns an empty result set. No error message means the grant succeeded.
Notes
- Executing this command requires the
workspace_adminorsecurity_adminrole, orWITH GRANT OPTIONon the target object. - Follow the principle of least privilege: grant only the minimum permissions a user needs to complete their work.
- Granting roles (
GRANT ROLE) is the recommended permission management approach, as it simplifies bulk management and permission revocation. - Use
WITH GRANT OPTIONwith caution, as the grantee may propagate the permission to other users. - Use
SHOW GRANTS TO USER user_nameto verify the grant result.
