Find out the history of SQL queries

后端 未结 3 1845
耶瑟儿~
耶瑟儿~ 2020-12-02 15:04

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 t

相关标签:
3条回答
  • 2020-12-02 15:42
        select v.SQL_TEXT,
               v.PARSING_SCHEMA_NAME,
               v.FIRST_LOAD_TIME,
               v.DISK_READS,
               v.ROWS_PROCESSED,
               v.ELAPSED_TIME,
               v.service
          from v$sql v
    where to_date(v.FIRST_LOAD_TIME,'YYYY-MM-DD hh24:mi:ss')>ADD_MONTHS(trunc(sysdate,'MM'),-2)
    

    where clause is optional. You can sort the results according to FIRST_LOAD_TIME and find the records up to 2 months ago.

    0 讨论(0)
  • 2020-12-02 15:45

    For recent SQL:

    select * from v$sql
    

    For history:

    select * from dba_hist_sqltext
    
    0 讨论(0)
  • 2020-12-02 16:00

    You can use this sql statement to get the history for any date:

    SELECT * FROM V$SQL V where  to_date(v.FIRST_LOAD_TIME,'YYYY-MM-DD hh24:mi:ss') > sysdate - 60
    
    0 讨论(0)
提交回复
热议问题