oracle一个大事务的sql往往不知道运行到了哪里,可以使用如下sql查看执行进度。
复制代码 代码如下:
set linesize 400;
set pagesize 400;
col sql_text format a100;
col opname format a15;
select se.sid,
opname,
trunc (sofar / totalwork * 100, 2) pct_work,
elapsed_seconds elapsed,
round (elapsed_seconds * (totalwork – sofar) / sofar) remain_time,
sql_text
from v$session_longops sl, v$sqlarea sa, v$session se
where sl.sql_hash_value = sa.hash_value
and sl.sid = se.sid
and sofar != totalwork
order by start_time;
或者
复制代码 代码如下:
set linesize 400;
set pagesize 400;
set long 4000;
col sql_fulltext format a100;
col opname format a15;
select se.sid,
opname,
trunc (sofar / totalwork * 100, 2) pct_work,
elapsed_seconds elapsed,
round (elapsed_seconds * (totalwork – sofar) / sofar) remain_time,
sql_fulltext
from v$session_longops sl, v$sqlarea sa, v$session se
where sl.sql_hash_value = sa.hash_value
and sl.sid = se.sid
and sofar != totalwork
order by start_time;