SET ROLE

语法

SET ROLE { role | NONE }

Contents

  1. 语法
  2. 描述
  3. 示例

描述

SET ROLE 语句为当前会话启用一个 角色,以及该角色关联的所有权限。要取消角色,请使用 NONE

如果指定了不存在或未分配给用户的角色,则会出现 ERROR 1959 (OP000): Invalid role specification 错误。

如果用户已分配了默认角色,则在用户连接时会隐式执行自动 SET ROLE。请参见 SET DEFAULT ROLE

示例

SELECT CURRENT_ROLE;
+--------------+
| CURRENT_ROLE |
+--------------+
| NULL         |
+--------------+

SET ROLE staff;

SELECT CURRENT_ROLE;
+--------------+
| CURRENT_ROLE |
+--------------+
| staff        |
+--------------+

SET ROLE NONE;

SELECT CURRENT_ROLE();
+----------------+
| CURRENT_ROLE() |
+----------------+
| NULL           |
+----------------+

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.