2011-12-08 45 views

回答

2
select a.sql_id,dbms_lob.substr(b.sql_text,4000,1) from dba_hist_active_sess_history a, dba_hist_sqltext b 
where sample_time between to_date('20110711:15:20','yyyymmdd:hh24:mi') 
and to_date('20110711:15:21','yyyymmdd:hh24:mi') and b.sql_id=a.sql_id 
union all 

select a.sql_id ,dbms_lob.substr(b.sql_text,4000,1)from v$active_session_history a ,v$sqlarea b 
where sample_time between to_date('20110711:15:20','yyyymmdd:hh24:mi') and 
to_date('20110711:15:21','yyyymmdd:hh24:mi') and b.sql_id=a.sql_id 

Read more: Oracle SQL History | eHow.com

+0

對不起丹尼爾,再次詢問上述不工作。你可以幫助實際工作查詢。 –

+0

不工作是什麼意思? –

+0

從dba_hist_active_sess_history a,dba_hist_sqltext b中選擇a.sql_id,substr(b.sql_text,1,1000),其中to_date('11082011:02:22:19','mmddyyyy:hh:mi:ss')之間的a.sample_time和to_date('11082011:02:24:19','mmddyyyy:hh:mi:ss')和b.sql_id = a.sql_id union all –