You can create a role, grant privileges to the role, and manage privileges by role.
Create a role by using an SQL statement
You can use the CREATE ROLE statement to create a role. To create a role, you must have the CREATE ROLE privilege. For information about how to view your privileges, see View user privileges. If you do not have the CREATE ROLE privilege, contact the administrator to obtain the privilege. For information about how to grant privileges to a user, see Modify user privileges.
The SQL statement is as follows:
CREATE ROLE role_name
[ NOT IDENTIFIED
| IDENTIFIED BY password
] ;
where
NOT IDENTIFIED: If you specify this clause, a new role is not verified when it is enabled.IDENTIFIED BY password: This clause specifies the password to enable a role. If you specify this clause and grant the role to a user, the user must specify the password in theSET ROLEstatement to enable the role.If you do not specify the
NOT IDENTIFIEDorIDENTIFIED BY passwordclause, theNOT IDENTIFIEDclause is used for a new role by default.
Examples:
Create the
role1roleobclient> CREATE ROLE role1; Query OK, 0 rows affectedCreate a role named
role2and set its password to******obclient> CREATE ROLE role2 IDENTIFIED BY ******; Query OK, 0 rows affectedFor more information about the
CREATE ROLEstatement, see CREATE ROLE.