PLSQL专项学习之SYS_CONTEXT

11 篇文章 0 订阅

SYS_CONTEXT

目的:SYS_CONTEXT返回与上下文命名空间关联的参数的值。您可以在SQL和PL/SQL语句中使用此函数。

对于名称空间和参数,可以指定一个字符串或一个表达式,该表达式解析为一个字符串,指定一个名称空间或属性。必须已经创建了上下文名称空间,并且还必须使用DBMS_SESSION设置了关联的参数及其值。set_context过程。名称空间必须是有效的SQL标识符。参数名可以是任何字符串。它不区分大小写,但长度不能超过30个字节。 

Oracle提供了一个名为USERENV的内置名称空间,用于描述当前会话。下面案例列出了名称空间USERENV的预定义参数。

语法:

 

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

案例:

USERENV常用的预定义参数:

参数名称返回值

ACTION

标识模块(应用程序名称)中的位置,并通过DBMS_APPLICATION_INFO包或OCI进行设置。

AUDITED_CURSORID

返回触发审计的SQL的游标ID。此参数在细粒度审计环境中无效。如果在这样的环境中指定它,Oracle数据库总是返回NULL。

AUTHENTICATION_DATA

用于对登录用户进行身份验证的数据。对于经过认证的X.503证书会话,该字段以HEX2格式返回证书的上下文。

注意:可以使用语法的length参数更改AUTHENTICATION_DATAattribute的返回值。最多可接受4000个值。这是Oracle数据库实现这种更改的USERENV的惟一属性。

BG_JOB_ID

当前会话的作业ID(如果它是由Oracle数据库后台进程建立的)。如果会话不是由后台进程建立的,则为Null。

CLIENT_IDENTIFIER

返回应用程序通过DBMS_SESSION设置的标识符。SET_IDENTIFIER过程,OCI属性OCI_ATTR_CLIENT_IDENTIFIER,或Java类oracle .jdbc. oracleconnec.setclientidentifier。各种数据库组件都使用此属性来标识身份验证为相同数据库用户的轻量级应用程序用户。

CLIENT_INFO

返回最多64字节的用户会话信息,应用程序可以使用DBMS_APPLICATION_INFO包存储这些信息。

CURRENT_BIND

用于细粒度审计的绑定变量。

CURRENT_SCHEMA

当前模式中使用的默认模式的名称。可以在会话期间使用 ALTER session SET CURRENT_SCHEMA语句更改此值。

CURRENT_SCHEMAID

当前会话中使用的默认模式的标识符。

DB_NAME

数据库的名称,在DB_NAME初始化参数中指定。

DB_UNIQUE_NAME

数据库的名称,在db_unique_name初始化参数中指定。

HOST

客户机所连接的主机的名称。

INSTANCE

The instance identification number of the current instance.

INSTANCE_NAME

The name of the instance.

IP_ADDRESS

IP address of the machine from which the client is connected.

LANG

The ISO abbreviation for the language name, a shorter form than the existing 'LANGUAGE' parameter.

LANGUAGE

The language and territory currently used by your session, along with the database character set, in this form:

language_territory.characterset

MODULE

The application name (module) set through the DBMS_APPLICATION_INFO package or OCI.

NETWORK_PROTOCOL

Network protocol being used for communication, as specified in the 'PROTOCOL=protocol' portion of the connect string.

NLS_CALENDAR

The current calendar of the current session.

NLS_CURRENCY

The currency of the current session.

NLS_DATE_FORMAT

The date format for the session.

NLS_DATE_LANGUAGE

The language used for expressing dates.

NLS_SORT

BINARY or the linguistic sort basis.

NLS_TERRITORY

The territory of the current session.

OS_USER

Operating system user name of the client process that initiated the database session.

POLICY_INVOKER

The invoker of row-level security (RLS) policy functions.

PROXY_ENTERPRISE_IDENTITY

Returns the Oracle Internet Directory DN when the proxy user is an enterprise user.

PROXY_GLOBAL_UID

Returns the global user ID from Oracle Internet Directory for Enterprise User Security (EUS) proxy users; returns NULL for all other proxy users.

PROXY_USER

Name of the database user who opened the current session on behalf of SESSION_USER.

PROXY_USERID

Identifier of the database user who opened the current session on behalf of SESSION_USER.

SERVER_HOST

The host name of the machine on which the instance is running.

SERVICE_NAME

The name of the service to which a given session is connected.

SESSION_USER

For enterprises users, returns the schema. For other users, returns the database user name by which the current user is authenticated. This value remains the same throughout the duration of the session.

SESSION_USERID

Identifier of the database user name by which the current user is authenticated.

SESSIONID

The auditing session identifier. You cannot use this attribute in distributed SQL statements.

SID

The session number (different from the session ID).

STATEMENTID

The auditing statement identifier. STATEMENTID represents the number of SQL statements audited in a given session. You cannot use this attribute in distributed SQL statements. The correct auditing statement identifier can be seen only through an audit handler for standard or fine-grained audit.

TERMINAL

The operating system identifier for the client of the current session. In distributed SQL statements, this attribute returns the identifier for your local session. In a distributed environment, this is supported only for remote SELECT statements, not for remote INSERTUPDATE, or DELETEoperations. (The return length of this parameter may vary by operating system.)

AUTHENTICATION_TYPE

This parameter returned a value indicating how the user was authenticated. The same information is now available from the new AUTHENTICATION_METHOD parameter combined with IDENTIFICATION_TYPE.

CURRENT_USER

Use the SESSION_USER parameter instead.

CURRENT_USERID

Use the SESSION_USERID parameter instead.

EXTERNAL_NAME

This parameter returned the external name of the user. More complete information can now be obtained from the AUTHENTICATED_IDENTITYand ENTERPRISE_IDENTITY parameter.

 由于预定义参数比较多,就不一个一个翻译,其实看一下就可以明白的。

至此为止,欢迎浏览探讨。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张陈亚

您的鼓励,将是我最大的坚持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值