CREATE ROLE
Requires permissionRoles and access control →
Marked preset roles include the permission by default; a custom role qualifies when it inherits a role that includes it. Creating, configuring, and dropping custom roles share this permission.
Create a custom role to give a team scoped data access on top of a preset role. To set which role a custom role inherits from, follow CREATE ROLE with GRANT ROLE. See Roles and access control for the model.
note
Custom roles are available on the Enterprise plan.
Syntax​
CREATE ROLE [ IF NOT EXISTS ] <role_name>;
Creating a role that already exists returns an error. Use IF NOT EXISTS to silence that error.
Parameters​
| Parameter | Description | Required |
|---|---|---|
<role_name> | Name of the role. Must be at least three characters, start with a letter, and contain only letters, numbers, hyphens, and underscores. Names are case-insensitive and stored in lowercase. admin, builder, and explorer are reserved. | Yes |
IF NOT EXISTS | Skip creation without an error if a role with this name already exists. | No |
Examples​
Create a role​
CREATE ROLE finance;
Create a role and set its parent​
A new custom role has no platform privileges until it inherits from a preset or another custom role.
CREATE ROLE finance;
GRANT ROLE explorer TO ROLE finance;
Create a role only if it does not exist​
CREATE ROLE IF NOT EXISTS finance;