13.7.1.11 SET ROLE Statement语句

SET ROLE {
    DEFAULT
  | NONE
  | ALL
  | ALL EXCEPT role [, role ] ...
  | role [, role ] ...
}

SET ROLE modifies the current user's effective privileges within the current session by specifying which of its granted roles are active. SET ROLE通过指定当前用户授予的哪些角色处于活动状态,修改当前用户在当前会话中的有效权限。Granted roles include those granted explicitly to the user and those named in the mandatory_roles system variable value.已授予的角色包括明确授予用户的角色,以及在mandatory_roles系统变量值中命名的角色。

Examples:

SET ROLE DEFAULT;
SET ROLE 'role1', 'role2';
SET ROLE ALL;
SET ROLE ALL EXCEPT 'role1', 'role2';

Each role name uses the format described in Section 6.2.5, “Specifying Role Names”. 每个角色名称使用第6.2.5节,“指定角色名称”中描述的格式。The host name part of the role name, if omitted, defaults to '%'.角色名的主机名部分(如果省略)默认为'%'

Privileges that the user has been granted directly (rather than through roles) remain unaffected by changes to the active roles.直接(而不是通过角色)授予用户的权限不受活动角色更改的影响。

The statement permits these role specifiers:该语句允许以下角色说明符:

Note注意

SET DEFAULT ROLE and SET ROLE DEFAULT are different statements:SET DEFAULT ROLESET ROLE DEFAULT是不同的语句:

  • SET DEFAULT ROLE defines which account roles to activate by default within account sessions.SET DEFAULT ROLE定义默认情况下在帐户会话中激活哪些帐户角色。

  • SET ROLE DEFAULT sets the active roles within the current session to the current account default roles.SET ROLE DEFAULT将当前会话中的活动角色设置为当前帐户默认角色。

For role usage examples, see Section 6.2.10, “Using Roles”.有关角色使用示例,请参阅第6.2.10节,“使用角色”