The GRANT command is used to:
GRANT privilege_list ON priv_level TO user_identity [ROLE role_name]
GRANT privilege_list ON RESOURCE resource_name TO user_identity [ROLE role_name]
GRANT privilege_list ON WORKLOAD GROUP workload_group_name TO user_identity [ROLE role_name]
GRANT privilege_list ON COMPUTE GROUP compute_group_name TO user_identity [ROLE role_name]
GRANT privilege_list ON STORAGE VAULT storage_vault_name TO user_identity [ROLE role_name]
GRANT role_list TO user_identity
A comma-separated list of privileges to be granted. Currently supported privileges include:
view creation statements.Legacy privilege conversion:
Supports the following four forms:
Specifies the resource name, supporting % and * to match all resources, but does not support wildcards, such as res*.
Specifies the workload group name, supporting % and * to match all workload groups, but does not support wildcards.
Specifies the compute group name, supporting % and * to match all compute groups, but does not support wildcards.
Specifies the storage vault name, supporting % and * to match all storage vaults, but does not support wildcards.
Specifies the user to receive the privileges. Must be a user_identity created with CREATE USER. The host in user_identity can be a domain name. If it is a domain name, the effective time of the authority may be delayed by about 1 minute.
Specifies the role to receive the privileges. If the specified role does not exist, it will be created automatically.
A comma-separated list of roles to be assigned. The specified roles must exist.
Grant permissions to all catalogs and databases and tables to the user:
GRANT SELECT_PRIV ON ..* TO ‘jack’@‘%’;
Grant permissions to the specified database table to the user:
GRANT SELECT_PRIV,ALTER_PRIV,LOAD_PRIV ON ctl1.db1.tbl1 TO ‘jack’@‘192.8.%’;
Grant permissions to the specified database table to the role:
GRANT LOAD_PRIV ON ctl1.db1.* TO ROLE ‘my_role’;
Grant access to all resources to users:
GRANT USAGE_PRIV ON RESOURCE * TO ‘jack’@‘%’;
Grant the user permission to use the specified resource:
GRANT USAGE_PRIV ON RESOURCE ‘spark_resource’ TO ‘jack’@‘%’;
Grant access to specified resources to roles:
GRANT USAGE_PRIV ON RESOURCE ‘spark_resource’ TO ROLE ‘my_role’;
Grant the specified role to a user:
GRANT ‘role1’,‘role2’ TO ‘jack’@‘%’;
Grant the specified workload group ‘g1’ to user jack:
GRANT USAGE_PRIV ON WORKLOAD GROUP ‘g1’ TO ‘jack’@‘%’;
Match all workload groups granted to user jack:
GRANT USAGE_PRIV ON WORKLOAD GROUP ‘%’ TO ‘jack’@‘%’;
Grant the workload group ‘g1’ to the role my_role:
GRANT USAGE_PRIV ON WORKLOAD GROUP ‘g1’ TO ROLE ‘my_role’;
Allow jack to view the creation statement of view1 under db1:
GRANT SHOW_VIEW_PRIV ON db1.view1 TO ‘jack’@‘%’;
Grant user permission to use the specified compute group:
GRANT USAGE_PRIV ON COMPUTE GROUP ‘group1’ TO ‘jack’@‘%’;
Grant role permission to use the specified compute group:
GRANT USAGE_PRIV ON COMPUTE GROUP ‘group1’ TO ROLE ‘my_role’;
Grant user permission to use all compute groups:
GRANT USAGE_PRIV ON COMPUTE GROUP ‘*’ TO ‘jack’@‘%’;
Grant user permission to use the specified storage vault:
GRANT USAGE_PRIV ON STORAGE VAULT ‘vault1’ TO ‘jack’@‘%’;
Grant role permission to use the specified storage vault:
GRANT USAGE_PRIV ON STORAGE VAULT ‘vault1’ TO ROLE ‘my_role’;
Grant user permission to use all storage vaults:
GRANT USAGE_PRIV ON STORAGE VAULT ‘*’ TO ‘jack’@‘%’;
GRANT, WORKLOAD GROUP, COMPUTE GROUP, RESOURCE