如何查询长时间的操作何时结束
数据库中有一个视图中v$session_longops 可以记录操作6秒以上的SQL操作,并估计还剩余的完成时间,视图如下:
有一些关键的字段的解释如下:
OPNAME VARCHAR2(64) Brief description of the operation
TARGET VARCHAR2(64) The object on which the operation is carried out
SOFAR NUMBER The units of work done so far
TOTALWORK NUMBER The total units of work
START_TIME DATE The starting time of operation
TIME_REMAINING NUMBER Estimate (in seconds) of time remaining for the operation to complete
ELAPSED_SECONDS NUMBER The number of elapsed seconds from the start of operations
以下SQL就可以知道某一个SQL操作需要还要多久完成 :
Sqlplus “/ as sysdba”
SQL > select opname,target,TIME_REMAINING from V$SESSION_LONGOPS
如果查看某个操作系统上的Oracle进程执行的SQL
1、现象、问题描述
有时需要知道某一个Oracle进程在执行的SQL操作。
2、关键过程、根本原因分析
select sql_text,spid,v$session.program,process
from v$sqlarea,v$session,v$process
where v$sqlarea.address=v$session.sql_address
and v$sqlarea.hashvalue=v$session.sql_hash_value
and v$session.paddr=v$process.addr
and v$process.spid in= 11355 ;
注间: v$process.spid 表示在操作系统上的进程号。