close

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

oracle

[ORACLE] 실행된 SQL Query 목록 HISTORY

mysop 2022. 9. 7. 17:05
728x90
반응형
select * from dba_hist_sqltext

이 테이블에서 쿼리 기록을 확인해 볼수가 있다.

 

만일 기간을 직접 입력해서 확인해 보고 싶다면

 

SELECT * FROM V$SQL V where  to_date(v.FIRST_LOAD_TIME,'YYYY-MM-DD hh24:mi:ss') > sysdate - 60

 

이렇게 간단하게도 가능하고

 

조금더 자세한 기간을 잡고 싶다면

 

SELECT * FROM V$SQL V 
where to_date(v.FIRST_LOAD_TIME,'YYYY-MM-DD hh24:mi:ss') > '2022-09-07 09:00' 
and 
to_date(v.FIRST_LOAD_TIME,'YYYY-MM-DD hh24:mi:ss') < '2022-09-07 11:00'

이렇게 기간을 명시할 수 있다.

 

보다시피 FIRST_LOAD_TIME은 쿼리 실행시간이고

LAST_LOAD_TIME은 쿼리실행이 끝나는 시간이다.

 

출처 : https://stackoverflow.com/questions/14830875/find-out-the-history-of-sql-queries

 

Find out the history of SQL queries

An update SQL query was executed on the server, which caused many problems later. How can I get the list of update queries executed in last 2 months, so that I can trace the exact problematic SQL ...

stackoverflow.com

 

728x90
반응형