GRANT can also be used to assign a role to another role or a user.
For more information, see Role-based access control.
GRANT PRIVILEGE
Grants a permission to a role.Only an account_admin or a role owner can grant a permission to a role. To grant a permission, you must first have that permission granted to you.
Syntax
CREATE DATABASE or USAGE ANY DATABASE apply to the whole deployment and take no ON clause. For the list, see Account permissions.
To grant SELECT on specific columns of a table, use the column-list syntax:
SELECT on TABLE objects. For more information, see Column-level security.
Parameters
Examples
GrantUSAGE 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
The following code example grants the USAGE privilege on all current and future databases 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:
SELECT on specific columns of a table
The following code example grants the role user_role permission to read only the name and email columns from my_table:
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:
GRANT ROLE
Grants a role to either a user or another role, allowing the recipient to inherit the permissions associated with the granted role.Syntax
Parameters
Examples
Grant a role to another role The following code example assigns therole_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: