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_demothe permission to create aVIRTUAL CLUSTERin thelakehouse_publicworkspace: - Authorize the user
uat_demoto modify theVIRTUAL CLUSTERnameddefault: - Grant the user
uat_demothe permissions to create tables and views under thepublicschema: - Grant the user
uat_demopermission to query all tables and views under thepublicschema: - Permissions for the user
uat_demoauthorized to the roleuser_adminto create tables and views in thesecurityschema under thelakehouse_publicworkspace:
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.
