- Categories:
Context functions (General)
IS_ DATABASE_ ROLE_ ACTIVATED(SYS_ CONTEXT 函数)¶
Returns the VARCHAR value 'TRUE' if a database role is activated in the current session.
语法
实参
'SNOWFLAKE$SESSION'指定您要调用函数以返回有关当前会话的上下文信息。
'IS_DATABASE_ROLE_ACTIVATED'调用 IS_DATABASE_ROLE_ACTIVATED 函数。
'database_role'指定要检查的数据库角色。该名称可以是完全限定名称,也可以是相对名称。
返回
该函数返回以下 VARCHAR 值之一:
'TRUE'if the current user’s active primary role or secondary roles in the session inherits the privileges of the specified database role.'FALSE'if the specified database role isn’t in the user’s active role hierarchy, or if the database role doesn’t exist.
To compare this return value against the BOOLEAN value TRUE or FALSE, cast the return value to BOOLEAN. For example:
使用说明
-
This function isn’t supported in governance policies (such as masking policies, row access policies, or projection policies) applied to shared tables. Shared objects can’t access consumer session state.
-
若不指定完全限定名称,函数将按如下方式确定数据库角色的数据库上下文:
- 查询: 会话数据库(当前正在使用的数据库)。
- 数据保护策略的主体: 包含受保护表或视图的数据库。
- 共享: 使用者账户中的数据库。
-
此函数不能用于物化视图定义,因为该函数不是确定性的。
示例
使用相对名称检查当前数据库中的数据库角色:
使用完全限定名称检查其他数据库中的数据库角色: