What SQL and sessions are running?

GUIs like TOAD and Enterprise Manager can show this better, but they’re not always to hand. Every session active now or within the last minute is shown.

1set pages 9999 lines 132
2col username form a20
3col osuser form a20
4col program form a50
5col minutes form 999
6alter session set nls_date_format = 'Dy DD-Mon-YYYY HH24:MI:SS'
7/
8select distinct
9s.sid, s.username, s.osuser, s.program||' '||s.module program,
10s.status, s.last_call_Et/60 minutes, s.logon_time, w.state, w.event, w.seconds_in_wait ,
11q.sql_text
12from v$session s, v$sql q, v$session_wait w
13where ( s.status = 'ACTIVE' or last_call_et < 60 )
14and s.sql_hash_value = q.hash_value
15and s.sql_address = q.address
16and s.sid = w.sid
17order by s.sid
18/
19set pages 9999 lines 80 head on feed 6
April 20, 2007

  • Following are errors on 10.2.0.1.0 on WIN XP SP2-

    1SQL> set pages 9999 lines 132
    2SQL> col username form a20
    3SQL> col osuser form a20
    4SQL> col program form a50
    5SQL> col minutes form 999
    6SQL> alter session set nls_date_format = `Dy DD-Mon-YYYY HH24:MI:SS'
    7  2  /
    8alter session set nls_date_format = `Dy DD-Mon-YYYY HH24:MI:SS'
    9                                    *
    10ERROR at line 1:
    11ORA-00911: invalid character
    1SQL> select distinct
    2  2  s.sid, s.username, s.osuser, s.program||' `||s.module program,
    3  3  s.status, s.last_call_Et/60 minutes, s.logon_time, w.state, w.event, w.seconds_in_wait ,
    4  4  q.sql_text
    5  5  from v$session s, v$sql q, v$session_wait w
    6  6  where ( s.status = `ACTIVE' or last_call_et < 60 )
    7  7  and s.sql_hash_value = q.hash_value
    8  8  and s.sql_address = q.address
    9  9  and s.sid = w.sid
    10 10  order by s.sid
    11 11  /
    12where ( s.status = `ACTIVE' or last_call_et < 60 )
    13                            *
    14ERROR at line 6:
    15ORA-00923: FROM keyword not found where expected
  • Leave a Reply

    Your email address will not be published. Required fields are marked *