top of page
CerebroSQL

CURRENT_ROLE

Database: MySQL

68747470733a2f2f7374796c65732e7265646469746d656469612e636f6d2f74355f32716d366b2f7374796c65

CURRENT_ROLE()

Returns a utf8 string containing the current active roles for the
current session, separated by commas, or NONE if there are none. The
value reflects the setting of the sql_quote_show_create system
variable.

URL: https://dev.mysql.com/doc/refman/8.0/en/information-functions.html

Example

GRANT 'r1', 'r2' TO 'u1'@'localhost';
SET DEFAULT ROLE ALL TO 'u1'@'localhost';

mysql> SELECT CURRENT_ROLE();
+-------------------+
| CURRENT_ROLE() |
+-------------------+
| `r1`@`%`,`r2`@`%` |
+-------------------+
mysql> SET ROLE 'r1'; SELECT CURRENT_ROLE();
+----------------+
| CURRENT_ROLE() |
+----------------+
| `r1`@`%` |
+----------------+

bottom of page