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
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 (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 |
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:
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.
