Purpose
You can use this statement to create a role. You can use roles to manage database privileges.
You can add a privilege to a role and then grant the role to a user. The user can use the privilege after enabling the role.
Syntax
CREATE ROLE role_name
[ NOT IDENTIFIED
| IDENTIFIED BY password
] ;
Parameters
| Parameter | Description |
|---|---|
| role_name | The name of the role to be created. |
| NOT IDENTIFIED | Specifies not to use any verification method to enable the role. Note: If the NOT IDENTIFIED and IDENTIFIED clauses are omitted, NOT IDENTIFIED prevails by default. |
| IDENTIFIED BY password | The password for enabling the role. Note: A user granted this role must use the specified password for verification when attempting to enable the role by using the SET ROLE statement. |
Examples
Create a role named
role1.obclient> CREATE ROLE role1; Query OK, 0 rows affectedCreate a role named
role2and specify the password**1***for it.obclient> CREATE ROLE role2 IDENTIFIED BY **1***; Query OK, 0 rows affected