CREATE ROLE

Syntax

CREATE ROLE [IF NOT EXISTS] role_name
[WITH (createRoleOption [, ...])];

Description

Creates a new custom role within the organization. Requires MANAGE_MEMBERS privilege.

Arguments

WITH (createRoleOption [, …​])

Parameter Name
Description

IN ROLE (role_name [, ...])

One or more existing roles to which the new role is added as a new member. Default value: Empty list

Type: List of STRING

Valid values: See list of existing roles with LIST ROLES.

ROLE (role_name [, ...])

One or more existing roles that are added as members of the new role. Default value: Empty list

Type: List of STRING

Valid values: See list of existing roles with LIST ROLES.

Examples

Create a new role

<no-db>/<no-store># USE ROLE useradmin;
+------------+------------+------------+------------------------+
|  Type      |  Name      |  Command   |  Summary               |
+============+============+============+========================+
| role       | useradmin  | USE        | using role "useradmin" |
+------------+------------+------------+------------------------+
<no-db>/<no-store># CREATE ROLE IF NOT EXISTS new_role;
+------------+------------+------------+------------------------------------------+
|  Type      |  Name      |  Command   |  Summary                                 |
+============+============+============+==========================================+
| role       | new_role   | CREATE     | role "new_role" was successfully created |
+------------+------------+------------+------------------------------------------+

Create a new role under SysAdmin

<no-db>/<no-store># USE ROLE useradmin;
+------------+------------+------------+----------------------+
|  Type      |  Name      |  Command   |  Summary             |
+============+============+============+======================+
| role       | useradmin  | USE        | using role useradmin |
+------------+------------+------------+----------------------+
<no-db>/<no-store># CREATE ROLE IF NOT EXISTS cust_role WITH (IN ROLE (sysadmin));
+------------+------------+------------+------------------------------------------+
|  Type      |  Name      |  Command   |  Summary                                 |
+============+============+============+==========================================+
| role       | cust_role  | CREATE     | role "cust_role" was successfully        |
|            |            |            | created                                  |
+------------+------------+------------+------------------------------------------+

Create a new role under SysAdmin , adding new_role as a member

<no-db>/<no-store># USE ROLE useradmin;
+------------+------------+------------+----------------------+
|  Type      |  Name      |  Command   |  Summary             |
+============+============+============+======================+
| role       | useradmin  | USE        | using role useradmin |
+------------+------------+------------+----------------------+
<no-db>/<no-store># CREATE ROLE IF NOT EXISTS test_role WITH (IN ROLE (sysadmin), ROLE (new_role));
+------------+------------+------------+------------------------------------------+
|  Type      |  Name      |  Command   |  Summary                                 |
+============+============+============+==========================================+
| role       | test_role  | CREATE     | role "test_role" was successfully        |
|            |            |            | created                                  |
+------------+------------+------------+------------------------------------------+

Last updated