找出 SQL 查询的历史 [英] Find out the history of SQL queries

查看:29
本文介绍了找出 SQL 查询的历史的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器上执行了更新SQL查询,导致后来出现很多问题.

An update SQL query was executed on the server, which caused many problems later.

如何获取最近 2 个月执行的更新查询列表,以便准确跟踪有问题的 SQL 查询?

How can I get the list of update queries executed in last 2 months, so that I can trace the exact problematic SQL query?

推荐答案

    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 子句是可选的.可以按照FIRST_LOAD_TIME对结果进行排序,查找到2个月前的记录.

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

这篇关于找出 SQL 查询的历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆