GRANT
GRANT
Description
The GRANT command is used to grant specified privilege to the specified user or role.
Grant privilege for databases and tables:
GRANT privilege_list
ON db_name[.tbl_name]
TO user_identity [ROLE role_name]Grant resource privilege:
GRANT privilege_list
ON RESOURCE resource_name
TO user_identity [ROLE role_name]-
privilege_listList of privileges to be granted, separated by comma.
Currently PALO supports the following privileges:
ADMIN_PRIV:All privileges except node management.GRANT_PRIV:Privilege to grant privileges, including creating and dropping users and roles, granting and revoking privileges, setting passwords, etc.SELECT_PRIV:Privilege to read specified library or tableLOAD_PRIV:Privilege to load specified library or tableALTER_PRIV:Privilege to change the schema of specified library or tableCREATE_PRIV:Privilege to create specified library or tableDROP_PRIV:Privilege to drop specified library or tableUSAGE_PRIV:Privilege to use specified resource
In addition, there are two syntax sugar privileges that can be used for quick granting:
-
ALLSimilar to read and write privileges, which is equivalent to granting:
SELECT_PRIV,LOAD_PRIV,ALTER_PRIV,CREATE_PRIV,DROP_PRIVthese privileges.
-
READ_ONLYSimilar to read-only privilege, which is equivalent to
SELECT_PRIV。
Classification of privileges:
- Library and table privileges: SELECT_PRIV,LOAD_PRIV,ALTER_PRIV,CREATE_PRIV,DROP_PRIV
- Resource privilege: USAGE_PRIV
-
db_name[.tbl_name]supports the following three forms:*.*:Privileges can be applied to all libraries and all tables in library.db.*:Privileges can be applied to all tables under specified library.db.tbl:Privileges can be applied to specified table under specified library.
The specified library or table here can be a nonexistent library or table.
-
resource_namesupports the following two forms:*:Privileges are applied to all resources.resource:Privileges are applied to a specified resource.
The specified resource here can be a nonexistent resource.
-
user_identityThe
user_identitysyntax here is the same as the syntax inCREATE USERand must be theuser_identitycreated by using CREATE USER. Thehostinuser_identitycan be a domain name. If it is a domain name, the effective time of privilege may be delayed for about 1min.The privilege can also be granted to specified
ROLE, if the specifiedROLEdoes not exist, then it will be automatically created.
Example
-
Grant privileges on all libraries and tables to users
GRANT SELECT_PRIV ON *.* TO 'jack'@'%'; -
Grant privileges on specified libraries and tables to users
GRANT SELECT_PRIV,ALTER_PRIV,LOAD_PRIV ON db1.tbl1 TO 'jack'@'192.8.%'; -
Grant privileges on specified libraries and tables to users
GRANT LOAD_PRIV ON db1.* TO ROLE 'my_role'; -
Grant privileges on all resources to users
GRANT USAGE_PRIV ON RESOURCE * TO 'jack'@'%'; -
Grant privileges on specified resources to users
GRANT USAGE_PRIV ON RESOURCE 'odbc_resource' TO 'jack'@'%'; -
Grants privileges on use of specified resources to roles
GRANT USAGE_PRIV ON RESOURCE 'odbc_resource' TO ROLE 'my_role';
Keywords
GRANT