Grant Permissions
Function
Grants permissions to a user or role.
Syntax
GRANT (privilege,...) ON (resource,..) TO ((ROLE role_name) | (USER user_name),...);
Keywords
- ROLE: Specifies that the following role_name is a role.
- USER: Specifies that the following user_name is a user.
Precautions
- privilege must be one of the grantable permissions. If the grantee already has the corresponding permission on the resource or a parent resource, the grant fails. For supported privilege types, see Data Permission List.
- resource can be a database, table, view, column, or function. The formats are as follows:
- Database format: databases.db_name.
For supported privilege types for databases, see Data Permission List.
- Table format: databases.db_name.tables.table_name.
For supported privilege types for tables, see Data Permission List.
- View format: databases.db_name.tables.view_name.
Views support the same privilege types as tables. For details, refer to the table permission list description in Data Permission List.
- Column format: databases.db_name.tables.table_name.columns.column_name.
The only supported privilege type for columns is SELECT.
- Function format: databases.db_name.functions.function_name.
For supported privilege types for functions, see Data Permission List.
- Database format: databases.db_name.
Examples
- Grant the DROP database permission on database db1 to user user_name1.
GRANT DROP ON databases.db1 TO USER user_name1;
- Grant the SELECT permission on table tb1 in database db1 to user user_name1.
GRANT SELECT ON databases.db1.tables.tb1 TO USER user_name1;
- Grant the SELECT permission on table tb1 in database db1 to role role_name.
GRANT SELECT ON databases.db1.tables.tb1 TO ROLE role_name;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot