Saturday, April 7, 2018

Query to find the list of users connected to the database along with SQL Text

select sesion.sid,
                   sesion.serial#,
                   proces.spid,
                   substr(sesion.machine,1,20) box,
                   sesion.logon_time logon_date , to_char (sesion.logon_time, 'hh24:mi:ss') logon_time,
       sesion.username,
       sesion.status,
       sesion.PROGRAM,
       sesion.OSUSER,
       sesion.serial#,
       cpu_time,
       elapsed_time,
       sql_text
   from v$sqlarea sqlarea, v$session sesion, v$process proces
   where sesion.sql_hash_value = sqlarea.hash_value
   and sesion.sql_address    = sqlarea.address
   and sesion.username is not null
   and sesion.paddr = proces.addr;

To get a better view of the result, please execute this query against the database in SQL Developer or Toad.



No comments:

Post a Comment