ORACLE 查询SQL执行时间:
SELECT
C.sample_time 执行时间,
A.ELAPSED_TIME_DELTA / 1000000 "执行耗时(S)",
B.sql_text SQL文本,
to_char(SUBSTR(B.sql_text,1,400)) SQL文本截取
FROM dba_hist_sqlstat A
LEFT JOIN dba_hist_sqltext B ON A.sql_id = B.sql_id
LEFT JOIN dba_hist_active_sess_history C ON C.sql_id = B.sql_id
WHERE PARSING_SCHEMA_NAME= 'SCOTT'/*用户名(大写)*/ AND C.sample_time IS NOT NULL
ORDER BY C.sample_time DESC;
或者
SELECT A.sql_ID,B.begin_interval_time 执行时间,B.startup_time,
A.elapsed_time_delta/1000000 "执行耗时(S)",
T3.sql_text SQL文本,
to_char(SUBSTR(T3.sql_text,1,400)) SQL文本截取
FROM dba_hist_sqlstat A
LEFT JOIN DBA_HIST_SNAPSHOT B ON A.snap_id = B.snap_id
LEFT JOIN dba_hist_sqltext T3 ON A.sql_id = T3.sql_id
WHERE PARSING_SCHEMA_NAME= 'SCOTT'/*用户名(大写)*/
ORDER BY begin_interval_time DESC;
结果如下:
dba_hist_sqlstat 及问题语句分析:https://blog.csdn.net/qq_34556414/article/details/82180812
参考:oracle查询SQL语句执行的耗时和执行时间 https://blog.csdn.net/xiaochangwei789/article/details/23919531/