Mengembalikan string utf8mb3 yang berisi peran aktif saat ini untuk sesi saat ini, dipisahkan dengan koma, atau NONE jika tidak ada. Nilai mencerminkan pengaturan variabel sistem sql_quote_show_create.
GRANT 'r1', 'r2' TO 'u1'@'localhost';
SET DEFAULT ROLE ALL TO 'u1'@'localhost';
Suppose that an account is granted roles as follows:
GRANT 'r1', 'r2' TO 'u1'@'localhost';
SET DEFAULT ROLE ALL TO 'u1'@'localhost';
In sessions for u1, the initial CURRENT_ROLE() value names the default account roles. Using SET ROLE changes that:
SELECT CURRENT_ROLE();
+-------------------+
| CURRENT_ROLE() |
+-------------------+
| `r1`@`%`,`r2`@`%` |
+-------------------+
SET ROLE 'r1'; SELECT CURRENT_ROLE();
+----------------+
| CURRENT_ROLE() |
+----------------+
| `r1`@`%` |
+----------------+