Granting a Permission

Function

This statement is used to grant permissions to a user or role.

Syntax

1
GRANT (privilege,...) ON (resource,..) TO ((ROLE [db_name].role_name) | (USER user_name)),...);

Keywords

ROLE: The subsequent role_name must be a role.

USER: The subsequent user_name must be a user.

Precautions

Example

Run the following statement to grant user_name1 the permission to delete the db1 database:

1
GRANT DROP_DATABASE ON databases.db1 TO USER user_name1;

Run the following statement to grant user_name1 the SELECT permission of data table tb1 in the db1 database:

1
GRANT SELECT ON databases.db1.tables.tb1 TO USER user_name1;

Run the following statement to grant role_name the SELECT permission of data table tb1 in the db1 database:

1
GRANT SELECT ON databases.db1.tables.tb1 TO ROLE role_name;