SHOW ROLES

Description

Lists the meta information of the roles created under your account, including role name, creator, creation time, and comments.

Note: To query the role you are currently using, use the select current_role() statement.

Syntax

1. > SHOW ROLES [LIKE 'pattern'];

Examples

1. -- Show the roles currently under your account
2. mysql> show roles;
3. +-----------+---------+---------------------+----------+
4. | ROLE_NAME | CREATOR | CREATED_TIME        | COMMENTS |
5. +-----------+---------+---------------------+----------+
6. | moadmin   |       0 | 2023-04-19 06:37:58 |          |
7. | public    |       0 | 2023-04-19 06:37:58 |          |
8. +-----------+---------+---------------------+----------+
9. 2 rows in set (0.01 sec)

11. -- create a new role named rolex
12. mysql> create role rolex;
13. Query OK, 0 rows affected (0.02 sec)

15. -- Show the roles currently under your account
16. mysql> show roles;
17. +-----------+---------+---------------------+----------+
18. | ROLE_NAME | CREATOR | CREATED_TIME        | COMMENTS |
19. +-----------+---------+---------------------+----------+
20. | rolex     |       1 | 2023-04-19 06:43:29 |          |
21. | moadmin   |       0 | 2023-04-19 06:37:58 |          |
22. | public    |       0 | 2023-04-19 06:37:58 |          |
23. +-----------+---------+---------------------+----------+
24. 3 rows in set (0.01 sec)

26. -- Query the role you are currently using
27. mysql> select current_role();
28. +----------------+
29. | current_role() |
30. +----------------+
31. | moadmin        |
32. +----------------+
33. 1 row in set (0.00 sec)