知识大全 userenv和sys

Posted 标识符

篇首语:知识投资收益最大。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 userenv和sys相关的知识,希望对你有一定的参考价值。

  这两个函数用来记录连接的session信息 经常用于触发器中 记录客户端的连接信息(比如IP) 我比较关注的是sessionid和ip 但是 select userenv( sessionid )得到的并不是用户的sid 而是v$session中的audsid sid根据audsid再得到

  SQL> select sid from v$session where audsid=userenv( sessionid );

  SID

  

  

  至于sid和audsid的区别 自己也没太搞明白 网上摘了一段

   from asktom

  the audsid column is populated via a sequence and for normal

  sessions is the same as userenv( sessionid ) but for some background sessions it is not set

  (it es back as making the view not work

  So I d just ignore audsid for now and use SID

  下面记录了两个函数的具体用法

   USERENV(OPTION)

  返回当前的会话信息

  OPTION= ISDBA 若当前是DBA角色 则为TRUE 否则FALSE

  OPTION= LANGUAGE 返回数据库的字符集

  OPTION= SESSIONID 为当前会话标识符

  OPTION= ENTRYID 返回可审计的会话标识符

  OPTION= LANG 返回会话语言名称的ISO简记

  OPTION= INSTANCE 返回当前的实例

  OPTION= terminal 返回当前计算机名

  SELECT USERENV( LANGUAGE ) FROM DUAL;

   返回系统会话信息sys_context

  select

  SYS_CONTEXT( USERENV TERMINAL ) terminal

  SYS_CONTEXT( USERENV LANGUAGE ) language

  SYS_CONTEXT( USERENV SESSIONID ) sessionid

  SYS_CONTEXT( USERENV INSTANCE ) instance

  SYS_CONTEXT( USERENV ENTRYID ) entryid

  SYS_CONTEXT( USERENV ISDBA ) isdba

  SYS_CONTEXT( USERENV NLS_TERRITORY ) nls_territory

  SYS_CONTEXT( USERENV NLS_CURRENCY ) nls_currency

  SYS_CONTEXT( USERENV NLS_CALENDAR ) nls_calendar

  SYS_CONTEXT( USERENV NLS_DATE_FORMAT ) nls_date_format

  SYS_CONTEXT( USERENV NLS_DATE_LANGUAGE ) nls_date_language

  SYS_CONTEXT( USERENV NLS_SORT ) nls_sort

  SYS_CONTEXT( USERENV CURRENT_USER ) current_user

  SYS_CONTEXT( USERENV CURRENT_USERID ) current_userid

  SYS_CONTEXT( USERENV SESSION_USER ) session_user

  SYS_CONTEXT( USERENV SESSION_USERID ) session_userid

  SYS_CONTEXT( USERENV PROXY_USER ) proxy_user

  SYS_CONTEXT( USERENV PROXY_USERID ) proxy_userid

  SYS_CONTEXT( USERENV DB_DOMAIN ) db_domain

  SYS_CONTEXT( USERENV DB_NAME ) db_name

  SYS_CONTEXT( USERENV HOST ) host

  SYS_CONTEXT( USERENV OS_USER ) os_user

  SYS_CONTEXT( USERENV EXTERNAL_NAME ) external_name

  SYS_CONTEXT( USERENV IP_ADDRESS ) ip_address

  SYS_CONTEXT( USERENV NEORK_PROTOCOL ) neork_protocol

  SYS_CONTEXT( USERENV BG_JOB_ID ) bg_job_id

  SYS_CONTEXT( USERENV FG_JOB_ID ) fg_job_id

  SYS_CONTEXT( USERENV AUTHENTICATION_TYPE ) authentication_type

  SYS_CONTEXT( USERENV AUTHENTICATION_DATA ) authentication_data

  from dual ;

  其中 第二个参数的可选值如下

  AUTHENTICATION_DATA

  Data being used to authenticate the login user For X certificate authenticated sessions this field returns the context of the certificate in HEX format

  Note: You can change the return value of the AUTHENTICATION_DATA attribute using the length parameter of the syntax Values of up to are accepted This is the only attribute of USERENV for which Oracle implements such a change

  AUTHENTICATION_TYPE

  How the user was authenticated:

  DATABASE: username/password authentication

  OS: operating system external user authentication

  NEORK: neork protocol or ANO authentication

  PROXY: OCI proxy connection authentication

  BG_JOB_ID

  Job ID of the current session if it was established by an Oracle background process Null if the session was not established by a background process

  CLIENT_INFO

  Returns up to bytes of user session information that can be stored by an application using the DBMS_APPLICATION_INFO package

  CURRENT_SCHEMA

  Name of the default schema being used in the current schema This value can be changed during the session with an ALTER SESSION SET CURRENT_SCHEMA statement

  CURRENT_SCHEMAID

  Identifier of the default schema being used in the current session

  CURRENT_USER

  The name of the user whose privilege the current session is under

  CURRENT_USERID

  User ID of the user whose privilege the current session is under

  DB_DOMAIN

  Domain of the database as specified in the DB_DOMAIN initialization parameter

  DB_NAME

  Name of the database as specified in the DB_NAME initialization parameter

  ENTRYID

  The available auditing entry identifier You cannot use this option in distributed SQL statements To use this keyword in USERENV the initialization parameter AUDIT_TRAIL must be set to true

  EXTERNAL_NAME

  External name of the database user For SSL authenticated sessions using v certificates this field returns the distinguished name (DN) stored in the user certificate

  FG_JOB_ID

  Job ID of the current session if it was established by a client foreground process Null if the session was not established by a foreground process

  HOST

  Name of the host machine from which the client has connected

  INSTANCE

  The instance identification number of the current instance

  IP_ADDRESS

  IP address of the machine from which the client is connected

  ISDBA

  TRUE if you are logged on as SYS

  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 the form:language_territory characterset

  NEORK_PROTOCOL

  Neork protocol being used for munication 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 username of the client process that initiated the database session

  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

  SESSION_USER

  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 option in distributed SQL statements

  TERMINAL

  The operating system identifier for the client of the current session In distributed SQL statements this option returns the identifier for your local session In a distributed environment this is supported only for remote SELECT statements not for remote INSERT UPDATE or DELETE operations

cha138/Article/program/Oracle/201311/16831

相关参考

SYS速分法-中水处理技术

一、中水概念:   中水是指生活污水经过处理后,达到规定的水质标准,可在一定范围内重复使用的非饮用水。中水设施,是指中水的水处理、集水、供水以及计量、检测等设施。中水主要

SYS速分法-中水处理技术

一、中水概念:   中水是指生活污水经过处理后,达到规定的水质标准,可在一定范围内重复使用的非饮用水。中水设施,是指中水的水处理、集水、供水以及计量、检测等设施。中水主要

SYS速分法-中水处理技术

一、中水概念:   中水是指生活污水经过处理后,达到规定的水质标准,可在一定范围内重复使用的非饮用水。中水设施,是指中水的水处理、集水、供水以及计量、检测等设施。中水主要

知识大全 oracle从备份的控制文件进行完全恢复

  oracle从备份的控制文件进行完全恢复  SYS@orcl#shutdownabort;  ORACLE例程已经关闭  SYS@orcl#  oracle@oracle:~/product//d

知识大全 和权限有关的表介绍

  SQL>selecttable_namefromdictwheretable_namelike%PRIV%;    SQL>select*fromuser_sys_privs;查看直接

知识大全 oracle系统表

  数据字典dict总是属于Oracle用户sys的  用户  selectusernamefromdba_users;  改口令  alteruserspgroupidentifiedbyspgte

知识大全 如何编写排序菜单sort

  在要排序的块上建立whenmouseclicktrigger代码  :globalmouserecord:=:systemmouse_record;  :globalmouseitem:=:sys

知识大全 建立核心设定档

  FreeBSd并未提供任何图型界面的核心设定程序您目前能够的编辑方式就是以您最熟悉喜爱的文字编辑器来编辑设定它核心设定文件存放的位置在/usr/src/sys/i/conf/目录下(针对兼容IBM

知识大全 C#判断硬盘上的文件是否存在方法

C#判断硬盘上的文件是否存在方法  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  命名空间:Sys

知识大全 php技巧:几个比较实用的PHP函数

php技巧:几个比较实用的PHP函数  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  sys_ge