GRANT

Grants permissions to a role. Can also be used to grant a role to another role or a user.

For more information, see Role-based access control.

Syntax

GRANT <permission> ON <object_type> <object_name> TO <role_name>

or

GRANT ROLE <role_name> TO { USER <user_name> | ROLE <role2_name> }

Parameters

Parameter Description
<permission> The name of the permission to grant to a role. Permissions that can be granted depend on the object they are granted on - for a full list see Permissions.
<object_type> The object to grant permissions on - either DATABASE or ENGINE.
<object_name> The name of the database or engine to grant permissions on.
<role_name> The name of the role.
<user_name> The name of the user for the role grant.
<role2_name> The name of the role for the role grant.

Example

The following command will grant USAGE permission on the database my_db to the role user_role.

GRANT USAGE ON DATABASE my_db TO user_role;

Example 2

The following command will grant USAGE permissions on all databases in the account dev to the role user_role.

GRANT USAGE ANY DATABASE ON ACCOUNT dev TO user_role;

Example 3

The following command will grant SELECT permission on table my_table to the role user_role.

GRANT SELECT ON TABLE my_table TO user_role;