CREATE GROUP
- reference
- Couchbase Server 8.0
The CREATE GROUP statement enables you to create a group.
Purpose
Use the CREATE GROUP statement to define a new group within the Couchbase Server Role-Based Access Control (RBAC) system. You can specify the group’s name, description, and assign it one or more roles.
By creating groups, you can organize users and assign roles collectively. When you add users to a group, they automatically inherit the roles assigned to that group.
RBAC Privileges
To execute the CREATE GROUP statement, you must have either the Full Admin or the Security Admin role. For more information about user roles, see Authorization.
Syntax
create-group ::= 'CREATE' 'GROUP' ( 'IF' 'NOT' 'EXISTS' )? name
( 'WITH' description )?
( 'ROLE' rbac-role | 'ROLES' rbac-role ( ',' rbac-role )* | 'NO' 'ROLES' )

name |
(Required) The unique identifier for the new group. |
description |
(Optional) A quoted string containing the description for the group. |
rbac-role |
(Required) Add Roles |
When creating a group, you can grant roles to them using one of the following options:
|
IF NOT EXISTS Clause
The optional IF NOT EXISTS
clause enables the statement to complete successfully when the specified group already exists.
If a group with the same name already exists, then:
-
If this clause is not present, an error is generated.
-
If this clause is present, the statement does nothing and completes without error.
Add Roles
rbac-role ::= role ( 'ON' keyspace-ref )?

role |
One of the RBAC role names predefined by Couchbase Server. For the following roles, you can use their short forms as well:
|
keyspace-ref |
Keyspace Reference
keyspace-ref ::= keyspace-path | keyspace-partial

keyspace-path ::= ( namespace ':' )? bucket ( '.' scope '.' collection )?

keyspace-partial ::= collection

Use keyspace reference to specify the target keyspace. For more information about each element, see the Keyspace Reference section in the FROM clause.
Examples
sales
and assign it the query_select
roleCREATE GROUP sales ROLE query_select ON `travel-sample`.`inventory`.`airline`;
travelagents
and assign it multiple rolesCREATE GROUP travelagents
WITH "Sample travel agents group"
ROLES data_reader ON `travel-sample`.`inventory`.`airline`,
select ON `travel-sample`.`inventory`.`landmark`;
support
if it does not already existCREATE GROUP IF NOT EXISTS support ROLE query_update
ON `travel-sample`.`inventory`.`airport`;
Related Links
-
To create a new user, see CREATE USER.
-
To update an existing group, see ALTER GROUP.
-
To delete a group, see DROP GROUP.