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)
  10. -- create a new role named rolex
  11. mysql> create role rolex;
  12. Query OK, 0 rows affected (0.02 sec)
  13. -- Show the roles currently under your account
  14. mysql> show roles;
  15. +-----------+---------+---------------------+----------+
  16. | ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |
  17. +-----------+---------+---------------------+----------+
  18. | rolex | 1 | 2023-04-19 06:43:29 | |
  19. | moadmin | 0 | 2023-04-19 06:37:58 | |
  20. | public | 0 | 2023-04-19 06:37:58 | |
  21. +-----------+---------+---------------------+----------+
  22. 3 rows in set (0.01 sec)
  23. -- Query the role you are currently using
  24. mysql> select current_role();
  25. +----------------+
  26. | current_role() |
  27. +----------------+
  28. | moadmin |
  29. +----------------+
  30. 1 row in set (0.00 sec)