查看oracle数据库最近执行了哪些sql语句

时间:2022-09-08 14:51:51
SELECT b.sql_text,                                            --content of SQL
                  a.machine,                     --which machine run this code
                            a.username, a.module,
                                                 -- the method to run this SQL
                                                 c.sofar / totalwork * 100,
                                                            --conplete percent
       c.elapsed_seconds,                                           --run time
                         c.time_remaining                 --remain to run time
  FROM v$session a, v$sqlarea b, v$session_longops c
 WHERE a.sql_hash_value = b.hash_value(+) AND a.SID = c.SID(+)
       AND a.serial# = c.serial#(+)
       --AND a.sid=139

oracle 最近执行过的sql语句:

 

SELECT   sql_text, last_load_time
    FROM v$sql
   WHERE last_load_time IS NOT NULL
ORDER BY last_load_time DESC

 

 

   ----监控concurrent 正在执行的sql --
SELECT a.sid, a.serial#, b.sql_text
  FROM v$session a, v$sqltext b
 WHERE a.sql_address = b.address
  --AND a.sid = <...>
 ORDER BY b.piece