GRANT ROLE

statementpartialAccess control (grants, roles)

docs.snowflake.com ↗

Assigns a role to a user or another role: - Granting a role to another role creates a “parent-child” relationship between the roles (also referred to as a role hierarchy). - Granting a role to a user enables the user to perform all operations allowed by the role (through the access privileges granted to the role). For more details, see Overview of Access Control.

Syntax

supportedpartialnot supportednot scored

GRANT ROLE <name> TO ROLE <parent_role_name> [ WITH GRANT OPTION ]

GRANT ROLE <name> TO USER <user_name>
  [ { FOR INTERVAL <interval> | UNTIL <timestamp> } [ RESET EXPIRATION ] ]

Parameters

NameRequiredDescription
nameSpecifies the identifier for the role to grant. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
ROLE parent_role_nameGrants the role to the specified role.
USER user_nameGrants the role to the specified user.
FOR INTERVAL intervalSpecifies that the grant of the role to the user expires after the specified length of time. Specify interval as a quoted string in the form 'integer unit', where: integer is a positive whole number. unit is MINUTE, HOUR, or DAY, or the plural form (MINUTES, HOURS, or DAYS). The unit is case-insensitive. For example, '30 MINUTES', '24 HOURS', or '7 DAYS'. You can specify only one unit; for example, '1 DAY 12 HOURS' isn’t supported. To specify 36 hours, use '36 HOURS'.
UNTIL timestampSpecifies that the grant of the role to the user expires at the specified timestamp. The timestamp must be in the future and must include an explicit time zone designator (Z) or a numeric offset (for example, +00:00 or -07:00). Timestamps without an offset aren’t supported. The following formats are supported: YYYY-MM-DDTHH:MM:SSZ YYYY-MM-DDTHH:MM:SS+00:00 YYYY-MM-DD HH:MM:SSZ YYYY-MM-DD HH:MM:SS+00:00
RESET EXPIRATIONSets the expiration of your existing grant of this role to this user to exactly the expiration in this statement. Without this clause, granting the role again keeps the longer of the existing and new lifetimes, so the new expiration takes effect only if it’s later. For example, use RESET EXPIRATION to shorten a temporary grant or to make a permanent grant temporary. For details, see Granting a role to a user again.
WITH GRANT OPTIONIf specified, allows the recipient role to grant the role to other roles. The recipient can include WITH GRANT OPTION on those grants. Default: No value, which means the recipient role can’t grant the role to other roles. The recipient still inherits the privileges of the granted role. Note WITH GRANT OPTION is valid on a grant to a role. GRANT ROLE ... TO USER ... WITH GRANT OPTION isn’t supported. The same clause is supported for database roles and application roles. See GRANT DATABASE ROLE and GRANT APPLICATION ROLE.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | Role | Role that is granted to a user or another role. Alternatively, use a role with the global MANAGE GRANTS privilege. Only the SECURITYADMIN role, or a higher role, has this privilege by default. The privilege can be granted to additional roles as needed. A role that was granted the role with WITH GRANT OPTION can also grant that role to other roles. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.

See also

Referenced by