How to obtain the ID (Session ID) of the current Oracle Session)

Source: Internet
Author: User

There are three methods to obtain the current Session ID (Session ID) of Oracle:

1.Below, this should be common.

SQL>Select sid from v $ mystat where rownum = 1;

SID

----------

140

2.The following is simpler:,HoweverOracle 10gAnd later versions.

SQL>Select userenv ('sid ') from dual;

USERENV ('sid ')

--------------

140

3.I use the following method sometimes.,Because you don't want to use the topSQLWrite a subquery,Found inOracle 9iNormal,HoweverOracle 10gUsually two rows are returned.,So you can no longer use it..

SQL>Select sid from v $ session where audsid = USERENV ('sessionid ');

SID

----------

140

142

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.