SYS_CONTEXT返回和当前名字空间相关的参数的值,可以使用在SQL/PLSQL中,但不可以用在并行查询或者RAC环境中
语法:
SYS_CONTEXT('NAMESPACE','PARAMETER')
详细的可以参见Oracle参考手册
一些用法:
SQL> show user
USER 为"LDY"
SQL> select sys_context('userenv','host') from dual;
SYS_CONTEXT('USERENV','HOST')
--------------------------------------------------------------------------
MSHOME\LIAODY
SQL> select sys_context('userenv','sessionid') from dual;
SYS_CONTEXT('USERENV','SESSIONID')
--------------------------------------------------------------------------
209
SQL> select sys_context('userenv','session_user') from dual;
SYS_CONTEXT('USERENV','SESSION_USER')
--------------------------------------------------------------------------
LDY
SQL> select sys_context('userenv','db_name') from dual;
SYS_CONTEXT('USERENV','DB_NAME')
--------------------------------------------------------------------------
oracle9i
SQL> select sys_context('userenv','instance') from dual;
SYS_CONTEXT('USERENV','INSTANCE')
--------------------------------------------------------------------------
1
SQL> select sys_context('userenv','language') from dual;
SYS_CONTEXT('USERENV','LANGUAGE')
--------------------------------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
SQL> select sys_context('userenv','os_user') from dual;
SYS_CONTEXT('USERENV','OS_USER')
--------------------------------------------------------------------------
LIAODY\Eagle
SQL>