Script to Monitor current User Activity in the Database

Source: Internet
Author: User

Execution Environment:     SQL, Sql*plus, isql*plusaccess privileges:     Requires Select privileges on view V$sqltext, V$session and V$process. Usage:     sqlplus/nolog      sql> connect sys;/<password>     sql> @sqltextInstructions: Copy the script into the file Sqltext.sql and execute it from Sql*plus connected as sys. Proofread this SCRIPT before USING it! Due to differences in the same-editors, e-mail packages, and operating systems handle text formatting (spaces, tabs, a ND carriage returns), this script is not being in a executable statewhen you first receive it. Check the script to ensure that errors ofthis type is corrected.
Description
The script displays the text of the SQL statements of the shared cursors in THESGA and information of the sessions Executi ng them. sql> @sqltextUnix PID  OS User   Oracle Us SID   serial# sql_text----------------------------------------- ---------------------------------16995     lsupport  SYS       7 */oracleoem */select value from                                            v$ Sysstat ORDER by statistic#16999     Lsupport  SYS          for    6769/* oracleoem */select value from                                            v$ Sesstat t where sid =: 1
References
Script
Set pagesize 66col C1 for A9col C1 heading ' OS User ' col C2 for A9col C2 heading ' Oracle User ' col B1 for A9col B1 heading '  Unix PID "Col B2 for 9999 justify Leftcol B2 heading" SID "Col B3 for 99999 justify Leftcol b3 heading" serial# "Col sql_text For A35break on B1 nodup on C1 nodup on C2 nodup on B2 nodup on B3 skip 3select c.spid B1, B.osuser C1, B.username C2, B. Sid B2, b.serial# b3,a.sql_text from  v$sqltext A, v$session B, v$process c   where a.address    = b.sql_address--< C4/>and b.status     = ' ACTIVE '/* CAN CHOOSE This OPTION is only to see--                                  actve TRANSACTION on that moment *   /an D b.paddr      = c.addr and   A.hash_value = b.sql_hash_value ORDER by c.spid,a.hash_value,a.piece/        
Disclaimer
 EXCEPT where expressly provided OTHERWISE, the information, Software,provided on a "as is" and "as AVAILABLE" BASIS. ORACLE expressly disclaimsall warranties of any KIND, WHETHER EXPRESS OR implied, including, but notlimited to, the Implie D warranties of merchantability, FITNESS for A Particularpurpose and Non-infringement. ORACLE makes NO WARRANTY that: (A) The resultsthat is obtained from the use of the software would be accurate ORRELIABL E or (B) the information, or other MATERIAL obtained would MEET yourexpectations. Any CONTENT, materials, information OR software downloaded Orotherwise obtained are done at YOUR OWN discretion and RISK.  ORACLE shall Haveno RESPONSIBILITY for any DAMAGE to YOUR computer SYSTEM OR LOSS of DATA thatresults from the DOWNLOAD of Any CONTENT, materials, information OR software.
ORACLE reserves the changes OR UPDATES to the software at ANYTIME without NOTICE. 

Script to Monitor current User Activity in the Database

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.