Monday, February 13, 2017

sql query history

SELECT
   h.sample_time,
   u.username,
   h.program,
   h.module,
   s.sql_text
FROM
   DBA_HIST_ACTIVE_SESS_HISTORY h,
   DBA_USERS u,
   DBA_HIST_SQLTEXT s
WHERE  sample_time >= SYSDATE - 60
   AND h.user_id=u.user_id
   AND h.sql_id = s.sql_iD
   and s.sql_text like '%'
   and u.username not in ('SYS')
ORDER BY h.sample_time
/

No comments: