Created
October 6, 2016 16:27
-
-
Save dotmaik1/564c986def4badbaacebad073007b72d to your computer and use it in GitHub Desktop.
Get what user is doing by SID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set verify off | |
| col username format a13 heading 'DB User' trunc | |
| col terminal for a10 | |
| col osuser format a12 heading 'OS User' trunc | |
| col sid format 9999 heading SID | |
| col serial# format 99999 heading SRL# | |
| col spid format a6 heading DBPROC | |
| col process format a8 heading APPPROC | |
| col mins format 9990.9 heading 'Status|mins' | |
| col program format a30 trunc | |
| --set linesize 180 | |
| --set pause on | |
| --set pause 'Mash Enter...' | |
| prompt User Processes Order by Status, Minutes in that status (desc), DB User | |
| accept wsid char prompt 'What is the SID to search for: ' | |
| select s.username, s.osuser, p.spid, s.process, s.sid, s.serial#, s.terminal, s.status, | |
| (s.last_call_et /60) mins, | |
| substr(substr(replace(s.program,'C:\'), instr(replace(s.program,'C:\'),'\')+1), | |
| instr(substr(replace(s.program,'C:\'), instr(replace(s.program,'C:\'),'\')+1) ,'\')+1 ) program, | |
| s.sql_hash_value, to_char(s.logon_time,'dd-mm-rrrr hh24:mi:ss') ini_sess | |
| from v$session s, v$process p | |
| where s.paddr = p.addr | |
| and s.sid= &wsid | |
| order by s.status, mins desc, username | |
| / | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment