2023-01-04 14:25阅读: 1288评论: 0推荐: 0

如何从 Oracle 数据库中的 SID 识别操作系统 PID

一、概述

我们想根据Oracle 数据库中的 sid 找出 OS PID,以检查与 OS 和数据库相关的性能。在 Linux 平台中,每个进程都有其进程 ID(PID),用户可以很容易地从 SID 中获取 PID(Identify OS PID from SID)。

二、解决方案

2.1 根据oracle的sid查询对应系统的pid

复制代码
Set lines 300
col sid format 9999
col username format a20
col osuser format a20

select a.sid, a.serial#,a.username, a.osuser, b.spid
from v$session a, v$process b
where a.paddr= b.addr
and a.sid='&Enter_sid'
order by a.sid;
复制代码

2.2 根据系统的OS pid,查询ORACLE的sid

要执行 CPU、内存和 I/O 等数据库性能,我们需要根据 OS PID(进程 ID)检查 SID。

得到SID后,可以使用v$session查看数据库中的sql_id,也可以使用v$sql视图在数据库中查找SQL文本。

复制代码
col sid format 9999
col username format a22
col osuser format a18

select p.spid,s.sid, s.serial#,s.username, s.osuser
from gv$session s, gv$process p
where s.paddr= p.addr
and p.spid='&Enter_spid'
order by p.spid;
复制代码

 

 

 

posted @   雪竹子  阅读(1288)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起