Two functions used to obtain session information in Oracle: oracle session

Source: Internet
Author: User

Two functions used to obtain session information in Oracle: oracle session

1. USERENV (OPTION)
Returns the current session information.
OPTION = 'isdba ': TRUE if the current role is a DBA; otherwise, FALSE.
OPTION = 'language' returns the character set of the database.
OPTION = 'sessionid' is the current session identifier.
OPTION = 'entryid' returns the auditable session identifier.
OPTION = 'lang 'returns the ISO Note of the session language name.
OPTION = 'instance' returns the current INSTANCE.
OPTION = 'terminal' returns the name of the current computer.
Select userenv ('language') from dual;
2. sys_context
Copy codeThe Code is as follows:
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', 'network _ Protocol') network_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

3. More information can be obtained by combining with the System View v $ session (applications used by the client, etc)
Copy codeThe Code is as follows:
Select *
From v $ session se,
(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', 'network _ Protocol') network_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) base
Where se. AUDSID = base. sessionid;
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.