Skip to main content
Grants permission or assignment to a role. 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

Account-level permissions such as 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:
Column-list syntax is only valid for SELECT on TABLE objects. For more information, see Column-level security.

Parameters

Examples

Grant 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:
Grant 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:
Grant access to a database, schema, and a specific table The following code example grants the role 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:
Grant 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:
Column-level grants are additive. If a subsequent grant adds more columns, the role can read the union of all granted columns. For more information, see Column-level security. Grant access to a database, schema, and all operations on a specific table The following code example grants the role 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:
Grant access to all existing and future tables or views in a schema The following code example grants 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 the role_name role to role_name_2, allowing role_name_2 to inherit all the permissions granted to role_name:
Grant a role to a user The following code example assigns the role_name role to user_name, allowing the user to inherit all the permissions granted to role_name: