在循环中执行的 SQL 查询
我需要您帮助解决以下查询。
SELECT
SQL_ID,
SNAP_ID,
EXECUTIONS_TOTAL,
EXECUTIONS_DELTA,
CPU_TIME_TOTAL,
CPU_TIME_DELTA,
ELAPSED_TIME_TOTAL,
ELAPSED_TIME_DELTA
from
WRH$_SQLSTAT
where
SQL_ID='807mzfr04qt1c' and
SNAP_ID in (19507,19508);
我必须每小时执行上述查询才能获取结果(snap_id 值在下一小时内从 19507-19508 更改为 19508-19509)。假设一整天,开始快照 ID 从 19507 开始,到 19530 结束。我需要帮助编写一个脚本,该脚本应该从开始 id(19507) 执行它,并将其与下一个 id(19508) 和下一个 id(19508) 成为起始 id,依此类推,从而执行直到到达结束 id(19530)。
I need your help with the following query.
SELECT
SQL_ID,
SNAP_ID,
EXECUTIONS_TOTAL,
EXECUTIONS_DELTA,
CPU_TIME_TOTAL,
CPU_TIME_DELTA,
ELAPSED_TIME_TOTAL,
ELAPSED_TIME_DELTA
from
WRH$_SQLSTAT
where
SQL_ID='807mzfr04qt1c' and
SNAP_ID in (19507,19508);
I have to execute the above query every hour to get the results(the snap_id value changes to 19508-19509 in next hour from 19507-19508). Let us say for an entire day the begin snap id started from 19507 and ended in 19530. I would need help in writing a script that should execute it from the start id(19507) and compare it with the next id(19508) and the next id(19508) becomes the start id and so on and thus execute until the end id(19530) is reached.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 DBMS_SCHEDULER。适用于您的 oracle 10g 版本。我有点困惑你在哪里尝试在 SQL 或 ORACLE 中实现它,因为你的问题在 oracle 10g 中被标记,并且你已经用 SQL 提到了你的问题。
但是如果您使用的是oracle 10g,您可以使用DBMS_SCHEDULER来实现它,如果您使用的是其他版本v7.3.4到9i oracle,使用DBMS_JOB来安排任务。
如果您使用MS SQL Server,我们可以通过创建计划作业来实现这一点。在 SQL Management Studio 中,导航到服务器,然后展开 SQL Server 代理项,最后展开作业文件夹以查看、编辑、添加计划作业。
You could use DBMS_SCHEDULER. for your version of oracle 10g. I am bit confused where are u trying to implement it in SQL or ORACLE, cause ur question is tagged in oracle 10g and u have mentioned your question with SQL.
But if you are using oracle 10g u can achieve it by using DBMS_SCHEDULER, incase you are uing some other version v7.3.4 to 9i oracle, use DBMS_JOB to schedule a task.
If u are using MS SQL Server us can achieve this by creating scheduled jobs. In SQL Management Studio, navigate to the server, then expand the SQL Server Agent item, and finally the Jobs folder to view, edit, add scheduled jobs.