Description
This document introduces how to use the GRANT statement in Lakehouse SQL to grant specified permissions to a user or role. By using the GRANT statement, you can perform fine-grained permission control on users to ensure data security and compliance.
Syntax
1. Grant specified permissions to a user
Parameter Description
1.workspacePriveleges Permissions to create objects under the workspace, such as CREATE VCLUSTER
2.workspaceObjectPriveleges Permissions to modify and show objects under the workspace
3.schemaPrivileges Permissions to create objects under the schema
4.schemaObjectPriveleges Permissions to modify, delete, and query tables under the schema
2 Grant specified permissions to a user
Parameter Description
workspacePrivileges
: Permissions to create objects in the workspace, such asCREATE SCHEMA
,CREATE VCLUSTER
, etc.workspaceObjectPrivileges
: Permissions to modify and query objects in the workspace, such asALTER
,DROP
,READ METADATA
, etc.schemaPrivileges
: Permissions to create objects in the schema, such asCREATE TABLE
,CREATE VIEW
,CREATE MATERIALIZED VIEW
, etc.schemaObjectPrivileges
: Permissions to modify and query objects in the schema, such asALTER
,DROP
,SELECT
, etc.role_name
: Role name, supporting custom roles and system default roles. System default roles includesystem_admin
,user_admin
,security_admin
,audit_admin
, etc.username
: User name.WITH GRANT OPTION
: Indicates that the authorized user can re-authorize these permissions to other users.
Usage Example
- Grant the user
uat_demo
the permission to create aVIRTUAL CLUSTER
in thelakehouse_public
workspace: - Authorize the user
uat_demo
to modify theVIRTUAL CLUSTER
nameddefault
: - Grant the user
uat_demo
the permissions to create tables and views under thepublic
schema: - Grant the user
uat_demo
permission to query all tables and views under thepublic
schema: - Permissions for the user
uat_demo
authorized to the roleuser_admin
to create tables and views in thesecurity
schema under thelakehouse_public
workspace:
By the above example, you can flexibly assign corresponding permissions to users or roles according to actual needs. Please ensure to follow the principle of least privilege when authorizing to reduce security risks.