【oracle】oracle 查询某用户某段时间内历史SQL

                    oracle 查询某用户某段时间内历史SQL

--如查询test用户2018年8月6号18~20点之间执行过的SQL
 

with his as (
select sql_id, sql_exec_start,user_id
    from dba_hist_active_sess_history t
where  user_id = (select user_id from dba_users where username = 'TEST')
and t.sql_exec_start between to_date('2018-08-06 180000','yyyy-mm-dd hh24miss') 
and to_date('2018-08-06 200000','yyyy-mm-dd hh24miss') order by 2 desc
)
select * from dba_hist_sqltext where sql_id in (select sql_id from his);

注:select user_id from dba_users where username = 'TEST'中的TEST用户名需要大写。

 

你可能感兴趣的:(【oracle】oracle 查询某用户某段时间内历史SQL)