1>通过TOP或TOPAS命令找出运行时间最长或是占用CPU最多的PID
2 找SID,SERIAL#;
SQL> select sid ,serial# ,username from V$session where username is not null;
SID SERIAL# USERNAME
---------- ---------- ------------------------------
315 133 SYS
324 92 U1
SELECT SID,SERIAL#, USERNAME,MACHINE FROM v$session b
WHERE b.paddr = (SELECT addr FROM v$process c WHERE c.spid = '&pid');
select spid, osuser, s.program from v$session s,v$process p where s.paddr=p.addr ;
SPID OSUSER PROGRAM
------------ ------------------------------ ------------------------------------------------
2053 oracle oracle@dba (PMON)
2055 oracle oracle@dba (PSP0)
2057 oracle oracle@dba (MMAN)
2059 oracle oracle@dba (DBW0)
2065 oracle oracle@dba (LGWR)
3>通过系统包作SQL_TRACE
Exec dbms_system.set_sql_trace_in_session(&SID,&SERIAL,TRUE);
Exec dbms_system.set_sql_trace_in_session(&SID,&SERIAL,FALSE);
查看当前trace文件
SQL> select c.value || '/' || d.instance_name || '_ora_' || to_char(a.spid,'fm99999') || '.trc' from v$process a, v$session b, v$parameter c, v$instance d where a.addr = b.paddr and b.audsid = userenv('sessionid') and c.name = 'user_dump_dest';
select s.sid,s.serial#,s.username,p.spid from v$session s,v$process p
where s.paddr=p.ADDR
根据显示的spid到dump目录下找trace文件
tkprof C:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_2020.trc c:\t1.txt 利用tkprof反编译跟踪文件
4>分析=
另附参照
V$PROCESS中的常用列
-ADDR:进程对象地址
-PID:oracle进程ID(相当于PK_ID)
-SPID:操作系统进程ID
MACHINE:一般企业公司机器名称结构是:
部门名+人名,这样以来你可以很容易确定操作者是谁.