ID EN
Information Functions

CURRENT_ROLE()

MySQL 8.4 🇮🇩 Bahasa Indonesia

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.

Syntax

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

Contoh

Example

Suppose that an account is granted roles as follows:

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

In sessions for u1, the initial CURRENT_ROLE() value names the default account roles. Using SET ROLE changes that:

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