SYS_CONTEXT
目的:SYS_CONTEXT返回与上下文命名空间关联的参数的值。您可以在SQL和PL/SQL语句中使用此函数。
对于名称空间和参数,可以指定一个字符串或一个表达式,该表达式解析为一个字符串,指定一个名称空间或属性。必须已经创建了上下文名称空间,并且还必须使用DBMS_SESSION设置了关联的参数及其值。set_context过程。名称空间必须是有效的SQL标识符。参数名可以是任何字符串。它不区分大小写,但长度不能超过30个字节。
Oracle提供了一个名为USERENV的内置名称空间,用于描述当前会话。下面案例列出了名称空间USERENV的预定义参数。
语法:
SYS_CONTEXT('namespace', 'parameter' [, length ])
案例:
USERENV常用的预定义参数:
参数名称 | 返回值 |
---|---|
| 标识模块(应用程序名称)中的位置,并通过DBMS_APPLICATION_INFO包或OCI进行设置。 |
| 返回触发审计的SQL的游标ID。此参数在细粒度审计环境中无效。如果在这样的环境中指定它,Oracle数据库总是返回NULL。 |
| 用于对登录用户进行身份验证的数据。对于经过认证的X.503证书会话,该字段以HEX2格式返回证书的上下文。 注意:可以使用语法的length参数更改AUTHENTICATION_DATAattribute的返回值。最多可接受4000个值。这是Oracle数据库实现这种更改的USERENV的惟一属性。 |
| 当前会话的作业ID(如果它是由Oracle数据库后台进程建立的)。如果会话不是由后台进程建立的,则为Null。 |
| 返回应用程序通过DBMS_SESSION设置的标识符。SET_IDENTIFIER过程,OCI属性OCI_ATTR_CLIENT_IDENTIFIER,或Java类oracle .jdbc. oracleconnec.setclientidentifier。各种数据库组件都使用此属性来标识身份验证为相同数据库用户的轻量级应用程序用户。 |
| 返回最多64字节的用户会话信息,应用程序可以使用DBMS_APPLICATION_INFO包存储这些信息。 |
| 用于细粒度审计的绑定变量。 |
| 当前模式中使用的默认模式的名称。可以在会话期间使用 ALTER session SET CURRENT_SCHEMA语句更改此值。 |
| 当前会话中使用的默认模式的标识符。 |
| 数据库的名称,在DB_NAME初始化参数中指定。 |
| 数据库的名称,在db_unique_name初始化参数中指定。 |
| 客户机所连接的主机的名称。 |
| The instance identification number of the current instance. |
| The name of the instance. |
| IP address of the machine from which the client is connected. |
| The ISO abbreviation for the language name, a shorter form than the existing ' |
| The language and territory currently used by your session, along with the database character set, in this form: language_territory.characterset |
| The application name (module) set through the |
| Network protocol being used for communication, as specified in the ' |
| The current calendar of the current session. |
| The currency of the current session. |
| The date format for the session. |
| The language used for expressing dates. |
|
|
| The territory of the current session. |
| Operating system user name of the client process that initiated the database session. |
| The invoker of row-level security (RLS) policy functions. |
| Returns the Oracle Internet Directory DN when the proxy user is an enterprise user. |
| Returns the global user ID from Oracle Internet Directory for Enterprise User Security (EUS) proxy users; returns |
| Name of the database user who opened the current session on behalf of |
| Identifier of the database user who opened the current session on behalf of |
| The host name of the machine on which the instance is running. |
| The name of the service to which a given session is connected. |
| 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. |
| Identifier of the database user name by which the current user is authenticated. |
| The auditing session identifier. You cannot use this attribute in distributed SQL statements. |
| The session number (different from the session ID). |
| The auditing statement identifier. |
| 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 |
| This parameter returned a value indicating how the user was authenticated. The same information is now available from the new |
| Use the |
| Use the |
| This parameter returned the external name of the user. More complete information can now be obtained from the |
由于预定义参数比较多,就不一个一个翻译,其实看一下就可以明白的。
至此为止,欢迎浏览探讨。