您的位置:首页 > 数据库

sys_context()函数用法解析

2016-12-02 16:23 507 查看
--sys_context

SYS_CONTEXT('namespace', 'parameter' [, length ])

SYS_CONTEXT returns the value of parameter associated with the context namespace at the current instant. You can use this function in both SQL and PL/SQL statements. SYS_CONTEXT must be executed locally.

The namespace must be a valid SQL identifier. The parameter name can be any string. It is not case sensitive, but it cannot exceed 30 bytes in length.

Oracle provides the following built-in namespaces:

USERENV - Describes the current session. The predefined parameters of namespace USERENV are listed in Table 5-11.

SYS_SESSION_ROLES - Indicates whether a specified role is currently enabled for the session. This namespace is available starting with Oracle Database 11g Release 2 (11.2.0.4).

parameter的值http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions184.htm#SQLRF06117
EODA@PROD1> select SYS_CONTEXT('USERENV','LANGUAGE') language from dual;

LANGUAGE
----------------------------------------------------------------------------------------------------
AMERICAN_AMERICA.AL32UTF8

EODA@PROD1> select SYS_CONTEXT('USERENV','CURRENT_USER') current_user from dual;

CURRENT_USER
----------------------------------------------------------------------------------------------------
EODA

EODA@PROD1> select sys_context('userenv', 'sid') from dual;

SYS_CONTEXT('USERENV','SID')
----------------------------------------------------------------------------------------------------
50
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  plsql sql