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

时间:2023-01-25 16:05:10
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

  

SELECT  *
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
ORDER BY b.piece