会话信息获取函数


  1. 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;
  2. SYS_CONTEXT
         
         
    1. SELECT SYS_CONTEXT('USERENV''TERMINAL') TERMINAL,
    2.        SYS_CONTEXT('USERENV''LANGUAGE'LANGUAGE,
    3.        SYS_CONTEXT('USERENV''SESSIONID') SESSIONID,
    4.        SYS_CONTEXT('USERENV''INSTANCE'INSTANCE,
    5.        SYS_CONTEXT('USERENV''ENTRYID') ENTRYID,
    6.        SYS_CONTEXT('USERENV''ISDBA') ISDBA,
    7.        SYS_CONTEXT('USERENV''NLS_TERRITORY') NLS_TERRITORY,
    8.        SYS_CONTEXT('USERENV''NLS_CURRENCY') NLS_CURRENCY,
    9.        SYS_CONTEXT('USERENV''NLS_CALENDAR') NLS_CALENDAR,
    10.        SYS_CONTEXT('USERENV''NLS_DATE_FORMAT') NLS_DATE_FORMAT,
    11.        SYS_CONTEXT('USERENV''NLS_DATE_LANGUAGE') NLS_DATE_LANGUAGE,
    12.        SYS_CONTEXT('USERENV''NLS_SORT') NLS_SORT,
    13.        SYS_CONTEXT('USERENV''CURRENT_USER'CURRENT_USER,
    14.        SYS_CONTEXT('USERENV''CURRENT_USERID') CURRENT_USERID,
    15.        SYS_CONTEXT('USERENV''SESSION_USER') SESSION_USER,
    16.        SYS_CONTEXT('USERENV''SESSION_USERID') SESSION_USERID,
    17.        SYS_CONTEXT('USERENV''PROXY_USER') PROXY_USER,
    18.        SYS_CONTEXT('USERENV''PROXY_USERID') PROXY_USERID,
    19.        SYS_CONTEXT('USERENV''DB_DOMAIN') DB_DOMAIN,
    20.        SYS_CONTEXT('USERENV''DB_NAME') DB_NAME,
    21.        SYS_CONTEXT('USERENV''HOST') HOST,
    22.        SYS_CONTEXT('USERENV''OS_USER') OS_USER,
    23.        SYS_CONTEXT('USERENV''EXTERNAL_NAME') EXTERNAL_NAME,
    24.        SYS_CONTEXT('USERENV''IP_ADDRESS') IP_ADDRESS,
    25.        SYS_CONTEXT('USERENV''NETWORK_PROTOCOL') NETWORK_PROTOCOL,
    26.        SYS_CONTEXT('USERENV''BG_JOB_ID') BG_JOB_ID,
    27.        SYS_CONTEXT('USERENV''FG_JOB_ID') FG_JOB_ID,
    28.        SYS_CONTEXT('USERENV''AUTHENTICATION_TYPE') AUTHENTICATION_TYPE,
    29.        SYS_CONTEXT('USERENV''AUTHENTICATION_DATA') AUTHENTICATION_DATA
    30.   FROM DUAL;
    其中,第二个参数的可选值如下:
    • AUTHENTICATION_DATA
      Data being used to authenticate the login user. For X.503 certificate authenticated sessions, this field returns the context of the certificate in HEX2 format.
      Note: You can change the return value of the AUTHENTICATION_DATA attribute using the length parameter of the syntax. Values of up to 4000 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
      NETWORK: network 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 64 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.503 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.
    • 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 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.
      (The return length of this parameter may vary by operating system.)


转自:http://zhaizhenxing.blog.51cto.com/643480/134745


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值