很多情况下我们需要获取或记录Oracle语句执行时间 其实简单的方法就能实现 具体代码如下
OracleE语句的执行时间需要使用 SET TIMING ON 例如
[oracle@jw ~]$ sqlplus /as sysdba SQLPlus: Release Production on 星期二 月 : : Copyright (c) Oracle Corporation All rights reserved
连接到
Oracle i Enterprise Edition Release Production With the Partitioning Oracle Label Security OLAP and Oracle Data Mining options JServer Release Production SQL> set timing on; SQL> select count() from tab; COUNT() 已用时间: : : SQL>
lishixinzhi/Article/program/Oracle/201311/16709
ALTER session SET nls_date_format='yyyy-mm-dd';
with mycte AS (
SELECT TRUNC( SYSDATE + 1, 'Q' ) AS TopDay FROM DUAL
)
SELECT TopDay -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,3) -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,6) -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,9) -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,12) -1 AS Result FROM mycte;
RESULT
----------
2013-03-31
2013-06-30
2013-09-30
2013-12-31
2014-03-31
-- 假如今天是 季度的最后一天(例如 2013-06-30 )
with mycte AS (
SELECT TRUNC( TO_DATE('20130630', 'YYYYMMDD') + 1, 'Q' ) AS TopDay FROM DUAL
)
SELECT TopDay -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,3) -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,6) -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,9) -1 AS Result FROM mycte UNION ALL
SELECT ADD_MONTHS(TopDay,12) -1 AS Result FROM mycte;
RESULT
----------
2013-06-30
2013-09-30
2013-12-31
2014-03-31
2014-06-30
以上就是关于获取或记录Oracle语句的执行时间全部的内容,包括:获取或记录Oracle语句的执行时间、oracle sql 最近5个季度的最后一天、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)