CURRENT_ROLE()

Description

Returns the role of the current session.

Syntax

  1. SELECT CURRENT_ROLE();

Examples

  1. mysql> select current_role();
  2. +----------------+
  3. | current_role() |
  4. +----------------+
  5. | moadmin |
  6. +----------------+
  7. 1 row in set (0.00 sec)
  8. -- Create a role and switch to the new role
  9. create role use_role_1;
  10. grant all on database * to use_role_1;
  11. grant use_role_1 to dump;
  12. set role use_role_1;
  13. mysql> select current_role();
  14. +----------------+
  15. | current_role() |
  16. +----------------+
  17. | use_role_1 |
  18. +----------------+
  19. 1 row in set (0.00 sec)