Reference and syntax for the GRANT command.
GRANT
can also be used to assign a role to another role or a user.
For more information, see Role-based access control.
Parameter | Description |
---|---|
<permission> | The name of the permission to grant to a role. Available permissions vary depending on the object that they apply to. For a full list, see Permissions. |
<object_type> | The type of object to grant permissions on. |
<object_name> | The name of the object to grant permissions on. |
<role_name> | The name of the role to grant the permission to. |
USAGE
on a single database
The following code example grants the USAGE
privilege on the db
database to the role user_role
, allowing it to access the database:
USAGE
on all databases within an account
The following code example grants the USAGE
privilege on all databases in the dev
account to the role user_role
, allowing access to them:
user_role
access to the db
database, the public
schema within the db
database, and permission to read data from the my_table
table in the public
schema:
user_role
access to the db
database, the public
schema within the db
database, and all permissions on the my_table
table in the public
schema:
user_role
access to the db
database, the public
schema within the db
database, and permission to query all existing and future tables or views in the public
schema:
Parameter | Description |
---|---|
<role_name> | The name of the role to grant. |
<user_name> | The name of the user to grant <role_name> to. |
<role_name_2> | The name of the role to assign the role to. |
role_name
role to role_name_2
, allowing role_name_2
to inherit all the permissions granted to role_name
:
role_name
role to user_name
, allowing the user to inherit all the permissions granted to role_name
: