> user()
> sys_context(‘USERENV’,’CURRENT_USER’)
> sys_context(‘USERENV’,’SESSION_USER’)
这些也可能与任何“当前用户”相关的值可能吗?
> sys_context(‘USERENV’,’CURRENT_SCHEMA’)
> sys_context(‘USERENV’,’AUTHENTICATED_IDENTITY’)
我特别感兴趣的是哪些可以改变,哪些可以改变它们,哪些不能改变价值,哪些具有不同的基于连接类型的值,以及哪些(总是)用于登录的模式数据库.
在我的大部分测试中,值总是相同的.唯一的例外是运行以下命令来改变’CURRENT_SCHEMA’:
alter session set current_schema=<SCHEMA>
执行以下结果的错误:
alter session set current_user=<USER> --even as sys/system,which is good I suppose
所以这里有一些安全/规则.但是,有一个理由背后有一个SESSION_USER和一个CURRENT_USER.我还假设user()可以是sys_context(‘USERENV’,’CURRENT_USER’)的快捷方式,但是我可以找不到关于此事的文档.
当前用户
The name of the database user whose privileges are currently active. This may change during the duration of a session to reflect the owner of any active definer’s rights object. When no definer’s rights object is active,CURRENT_USER returns the same value as SESSION_USER. When used directly in the body of a view definition,this returns the user that is executing the cursor that is using the view; it does not respect views used in the cursor as being definer’s rights.
SESSION_USER
The name of the database user at logon. For enterprise users,returns the schema. For other users,returns the database user name. This value remains the same throughout the duration of the session.
因此,在存储过程或函数中使用CURRENT_USER时,SESSION_USER和CURRENT_USER之间存在差异.
我不得不承认,我不知道“企业用户”一词是什么意思.
Btw:有三分之一:
SESSION_USERID
The identifier of the database user at logon.