Oracle/PLSQL: Sys_Context Function(轉自http://www.techonthenet.com)

In Oracle/PLSQL, the sys_context function can be used to retrieve information about the Oracle environment.

The syntax for the sys_context function is:

sys_context( namespace, parameter, [ length ] )

namespace is an Oracle namespace that has already been created. If the namespace of 'USERENV' is used, attributes describing the current Oracle session can be returned.

parameter is a valid attribute that has been set using the DBMS_SESSION.set_context procedure.

length is optional. It is the length of the return value in bytes. If this parameter is omitted or if an invalid entry is provided, the sys_context function will default to 256 bytes.


The valid parameters for the namespace called 'USERENV' are as follows:

Parameter Explanation Return Length
AUDITED_CURSORIDReturns the cursor ID of the SQL that triggered the auditN/A
AUTHENTICATION_DATAAuthentication data256
AUTHENTICATION_TYPEDescribes how the user was authenticated. Can be one of the following values: Database, OS, Network, or Proxy30
BG_JOB_IDIf the session was established by an Oracle background process, this parameter will return the Job ID. Otherwise, it will return NULL.30
CLIENT_IDENTIFIERReturns the client identifier (global context)64
CLIENT_INFOUser session information64
CURRENT_SCHEMAReturns the default schema used in the current schema30
CURRENT_SCHEMAIDReturns the identifier of the default schema used in the current schema30
CURRENT_SQLReturns the SQL that triggered the audit event64
CURRENT_USERName of the current user30
CURRENT_USERIDUserid of the current user30
DB_DOMAINDomain of the database from the DB_DOMAIN initialization parameter256
DB_NAMEName of the database from the DB_NAME initialization parameter30
ENTRYIDAvailable auditing entry identifier30
EXTERNAL_NAMEExternal of the database user256
FG_JOB_IDIf the session was established by a client foreground process, this parameter will return the Job ID. Otherwise, it will return NULL.30
GLOBAL_CONTEXT_MEMORYThe number used in the System Global Area by the globally accessed contextN/A
HOSTName of the host machine from which the client has connected54
INSTANCEThe identifier number of the current instance30
IP_ADDRESSIP address of the machine from which the client has connected30
ISDBAReturns TRUE if the user has DBA privileges. Otherwise, it will return FALSE.30
LANGThe ISO abbreviate for the language62
LANGUAGEThe language, territory, and character of the session. In the following format:
language_territory.characterset
52
NETWORK_PROTOCOLNetwork protocol used256
NLS_CALENDARThe calendar of the current session62
NLS_CURRENCYThe currency of the current session62
NLS_DATE_FORMATThe date format for the current session62
NLS_DATE_LANGUAGEThe language used for dates62
NLS_SORTBINARY or the linguistic sort basis62
NLS_TERRITORYThe territory of the current session62
OS_USERThe OS username for the user logged in30
PROXY_USERThe name of the user who opened the current session on behalf of SESSION_USER30
PROXY_USERIDThe identifier of the user who opened the current session on behalf of SESSION_USER30
SESSION_USERThe database user name of the user logged in30
SESSION_USERIDThe database identifier of the user logged in30
SESSIONIDThe identifier of the auditing session30
TERMINALThe OS identifier of the current session10
[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/95530/viewspace-1023318/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/95530/viewspace-1023318/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值