在Oracle数据库中,可以通过多种方式查看当前运行的进程。以下是几种常用的方法:
SELECT s.sid, s.serial#, s.username, s.status,
p.spid AS "OS PID", s.program, s.machine
FROM v$session s, v$process p
WHERE s.paddr = p.addr
ORDER BY s.username, s.program;
SELECT sid, serial#, username, event, wait_class, seconds_in_wait
FROM v$session_wait
WHERE wait_class != 'Idle'
ORDER BY seconds_in_wait DESC;
SELECT s.sid, s.serial#, s.username, s.status,
q.sql_text, q.sql_id
FROM v$session s, v$sqlarea q
WHERE s.sql_id = q.sql_id
AND s.status = 'ACTIVE';
在Linux/Unix系统上:
ps -ef | grep ora_ # 查看Oracle后台进程
ps -ef | grep LOCAL=NO # 查看Oracle用户进程
在Windows系统上:
tasklist | findstr "ORACLE"
SELECT l.session_id, s.serial#, s.username, s.osuser,
s.machine, s.program, l.oracle_username, l.locked_mode
FROM v$locked_object l, v$session s
WHERE l.session_id = s.sid
ORDER BY l.session_id;
SELECT holding_session, waiting_session, lock_type, mode_held, mode_requested
FROM dba_blockers;
ALTER SYSTEM KILL SESSION 'sid,serial#';
命令终止特定会话以上方法可以帮助您全面了解Oracle数据库中当前运行的进程状态。