返回顶部
首页 > 资讯 > 操作系统 >如何通过操作系统的进程号查看数据库的session
  • 423
分享到

如何通过操作系统的进程号查看数据库的session

2024-04-02 19:04:59 423人浏览 独家记忆
摘要

这篇文章将为大家详细讲解有关如何通过操作系统的进程号查看数据库的session,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。在工作中很多新手会遇到这种问题,就是操作系统显

这篇文章将为大家详细讲解有关如何通过操作系统的进程号查看数据库的session,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

在工作中很多新手会遇到这种问题,就是操作系统显示有个PID占用的CPU很高,导致整个系统运行很慢,

同时又不敢轻易的对这个PID进行KILL操作,很是头疼。

如何通过操作系统的进程号查看数据库的session

今天就和大家分享下,怎么通过操作系统的PID查找相应的数据库session和语句。

第一步:通过可以通过操作系统的PID查找数据库的v$process进程,语句如下:

select * from v$process where SPID='&PID'

第二步:查找相应的SESSION信息

SELECT SID,SERIAL#, USERNAME,MacHINE  
FROM v$session b    
WHERE b.paddr = (SELECT addr    
FROM v$process c    
WHERE c.spid = '&pid');

第三步:通过第二步查找出来的SID,可以进一步查找正在执行的sql语句

select b.sql_text 
from v$session a,v$sqlarea b 
where a.sql_hash_value=b.hash_value and a.sid=‘&SID';

另外可以通过下面这条语句查找后台进程的名字

SELECT s.SID SID, p.spid threadid, p.program processname, bg.NAME NAME  
FROM v$process p, v$session s, v$bgprocess bg    
WHERE p.addr = s.paddr    
AND p.addr = bg.paddr    
AND bg.paddr <> '00';

经过一番查询如果发现当前的session有问题,具体怎么判断是否有问题,会继续介绍。

操作系统的杀进程的操作很简单,语句如下kill -9 pid

附:V$PROCESS和V$SESSION的各字段说明

Column

Datatype

Description

ADDR

RAW(4 | 8)

Address of process state object

PID

NUMBER

oracle process identifier

SPID

VARCHAR2(12)

Operating system process identifier

USERNAME

VARCHAR2(15)

Operating system process username. Any two-task user coming across the network has "-T" appended to the username.

SERIAL#

NUMBER

Process serial number

TERMINAL

VARCHAR2(30)

Operating system terminal identifier

PROGRAM

VARCHAR2(48)

Program in progress

TRACEID

VARCHAR2(255)

Trace file identifier

BACKGROUND

VARCHAR2(1)

1 for a background process; NULL for a nORMal process

LATCHWaiT

VARCHAR2(8)

Address of latch the process is waiting for; NULL if none

LATCHSPIN

VARCHAR2(8)

Address of the latch the process is spinning on; NULL if none

PGA_USED_MEM

NUMBER

PGA memory currently used by the process

PGA_ALLOC_MEM

NUMBER

PGA memory currently allocated by the process (including free PGA memory not yet released to the operating system by the server process)

PGA_FREEABLE_MEM

NUMBER

Allocated PGA memory which can be freed

PGA_MAX_MEM

NUMBER

Maximum PGA memory ever allocated by the process

Column

Datatype

Description

SADDR

RAW(4 | 8)

Session address

SID

NUMBER

Session identifier

SERIAL#

NUMBER

Session serial number. Used to uniquely identify a session's objects. Guarantees that session-level commands are applied to the correct session objects if the session ends and another session begins with the same session ID.

AUDSID

NUMBER

Auditing session ID

PADDR

RAW(4 | 8)

Address of the process that owns the session

USER#

NUMBER

Oracle user identifier

USERNAME

VARCHAR2(30)

Oracle username

COMMAND

NUMBER

Command in progress (last statement parsed); for a list of values, see Table 7-5. These values also appear in the AUDIT_ACTIONS table.

OWNERID

NUMBER

The column contents are invalid if the value is 2147483644. Otherwise, this column contains the identifier of the user who owns the migratable session.

For operations using Parallel Slaves, interpret this value as a 4-byte value. The low-order 2 bytes of which represent the session number, and the high-order bytes the instance ID of the query coordinator.

TADDR

VARCHAR2(8)

Address of transaction state object

LOCKWAIT

VARCHAR2(8)

Address of lock waiting for; null if none

STATUS

VARCHAR2(8)

Status of the session:

  • ACTIVE - Session currently executing SQL

  • INACTIVE

  • KILLED - Session marked to be killed

  • CACHED - Session temporarily cached for use by Oracle*XA

  • SNIPED - Session inactive, waiting on the client

SERVER

VARCHAR2(9)

Server type (DEDICATED| SHARED| PSEUDO| NONE)

SCHEMA#

NUMBER

Schema user identifier

SCHEMANAME

VARCHAR2(30)

Schema user name

OSUSER

VARCHAR2(30)

Operating system client user name

PROCESS

VARCHAR2(12)

Operating system client process ID

MACHINE

VARCHAR2(64)

Operating system machine name

TERMINAL

VARCHAR2(30)

Operating system terminal name

PROGRAM

VARCHAR2(48)

Operating system program name

TYPE

VARCHAR2(10)

Session type

SQL_ADDRESS

RAW(4 | 8)

Used with SQL_HASH_VALUE to identify the SQL statement that is currently being executed

SQL_HASH_VALUE

NUMBER

Used with SQL_ADDRESS to identify the SQL statement that is currently being executed

SQL_ID

VARCHAR2(13)

SQL identifier of the SQL statement that is currently being executed

SQL_CHILD_NUMBER

NUMBER

Child number of the SQL statement that is currently being executed

PREV_SQL_ADDR

RAW(4 | 8)

Used with PREV_HASH_VALUE to identify the last SQL statement executed

PREV_HASH_VALUE

NUMBER

Used with SQL_HASH_VALUE to identify the last SQL statement executed

PREV_SQL_ID

VARCHAR2(13)

SQL identifier of the last SQL statement executed

PREV_CHILD_NUMBER

NUMBER

Child number of the last SQL statement executed

MODULE

VARCHAR2(48)

Name of the currently executing module as set by calling theDBMS_APPLICATION_INFO.SET_MODULE procedure

MODULE_HASH

NUMBER

Hash value of the above MODULE

ACTION

VARCHAR2(32)

Name of the currently executing action as set by calling theDBMS_APPLICATION_INFO.SET_ACTION procedure

ACTION_HASH

NUMBER

Hash value of the above action name

CLIENT_INFO

VARCHAR2(64)

Information set by the DBMS_APPLICATION_INFO.SET_CLIENT_INFO procedure

FIXED_TABLE_SEQUENCE

NUMBER

This contains a number that increases every time the session completes a call to the database and there has been an intervening select from a dynamic performance table. This column can be used by performance monitors to monitor statistics in the database. Each time the performance monitor looks at the database, it only needs to look at sessions that are currently active or have a higher value in this column than the highest value that the performance monitor saw the last time. All the other sessions have been idle since the last time the performance monitor looked at the database.

ROW_WAIT_OBJ#

NUMBER

Object ID for the table containing the row specified in ROW_WAIT_ROW#

ROW_WAIT_FILE#

NUMBER

Identifier for the datafile containing the row specified in ROW_WAIT_ROW#. This column is valid only if the session is currently waiting for another transaction to commit and the value ofROW_WAIT_OBJ# is not -1.

ROW_WAIT_BLOCK#

NUMBER

Identifier for the block containing the row specified in ROW_WAIT_ROW#. This column is valid only if the session is currently waiting for another transaction to commit and the value ofROW_WAIT_OBJ# is not -1.

ROW_WAIT_ROW#

NUMBER

Current row being locked. This column is valid only if the session is currently waiting for another transaction to commit and the value of ROW_WAIT_OBJ# is not -1.

LOGoN_TIME

DATE

Time of logon

LAST_CALL_ET

NUMBER

If the session STATUS is currently ACTIVE, then the value represents the elapsed time in seconds since the session has become active.

If the session STATUS is currently INACTIVE, then the value represents the elapsed time in seconds since the session has become inactive.

PDML_ENABLED

VARCHAR2(3)

This column has been replaced by column PDML_STATUS

FAILOVER_TYPE

VARCHAR2(13)

Indicates whether and to what extent transparent application failover (TAF) is enabled for the session:

  • NONE - Failover is disabled for this session

  • SESSION - Client is able to fail over its session following a disconnect

  • SELECT - Client is able to fail over queries in progress as well

See Also:

  • Oracle Database Concepts for more information on TAF

  • Oracle Database Net Services Administrator's Guide for information on configuring TAF

FAILOVER_METHOD

VARCHAR2(10)

Indicates the transparent application failover method for the session:

  • NONE - Failover is disabled for this session

  • BASIC - Client itself reconnects following a disconnect

  • PRECONNECT - Backup instance can support all connections from every instance for which it is backed up

FAILED_OVER

VARCHAR2(3)

Indicates whether the session is running in failover mode and failover has occurred (YES) or not (NO)

RESOURCE_CONSUMER_GROUP

VARCHAR2(32)

Name of the session's current resource consumer group

PDML_STATUS

VARCHAR2(8)

If ENABLED, the session is in a PARALLEL DML enabled mode. If DISABLED, PARALLEL DML enabled mode is not supported for the session. If FORCED, the session has been altered to force PARALLEL DML.

PDDL_STATUS

VARCHAR2(8)

If ENABLED, the session is in a PARALLEL DDL enabled mode. If DISABLED, PARALLEL DDL enabled mode is not supported for the session. If FORCED, the session has been altered to force PARALLEL DDL.

PQ_STATUS

VARCHAR2(8)

If ENABLED, the session is in a PARALLEL QUERY enabled mode. If DISABLED, PARALLEL QUERY enabled mode is not supported for the session. If FORCED, the session has been altered to force PARALLEL QUERY.

CURRENT_QUEUE_DURATION

NUMBER

If queued (1), the current amount of time the session has been queued. If not currently queued, the value is 0.

CLIENT_IDENTIFIER

VARCHAR2(64)

Client identifier of the session

BLOCKING_SESSION_STATUS

VARCHAR2(11)

Blocking session status:

  • VALID

  • NO HOLDER

  • GLOBAL

  • NOT IN WAIT

  • UNKNOWN

BLOCKING_INSTANCE

NUMBER

Instance identifier of blocking session

BLOCKING_SESSION

NUMBER

Session identifier of blocking session

SEQ#

NUMBER

Sequence number that uniquely identifies the wait. Incremented for each wait.

EVENT#

NUMBER

Event number

EVENT

VARCHAR2(64)

Resource or event for which the session is waiting

See Also: Appendix C, "Oracle Wait Events"

P1TEXT

VARCHAR2(64)

Description of the first additional parameter

P1

NUMBER

First additional parameter

P1RAW

RAW(4)

First additional parameter

P2TEXT

VARCHAR2(64)

Description of the second additional parameter

P2

NUMBER

Second additional parameter

P2RAW

RAW(4)

Second additional parameter

P3TEXT

VARCHAR2(64)

Description of the third additional parameter

P3

NUMBER

Third additional parameter

P3RAW

RAW(4)

Third additional parameter

WAIT_CLASS_ID

NUMBER

Identifier of the wait class

WAIT_CLASS#

NUMBER

Number of the wait class

WAIT_CLASS

VARCHAR2(64)

Name of the wait class

WAIT_TIME

NUMBER

A nonzero value is the session's last wait time. A zero value means the session is currently waiting.

SECONDS_IN_WAIT

NUMBER

If WAIT_TIME = 0, then SECONDS_IN_WAIT is the seconds spent in the current wait condition. IfWAIT_TIME > 0, then SECONDS_IN_WAIT is the seconds since the start of the last wait, andSECONDS_IN_WAIT - WAIT_TIME / 100 is the active seconds since the last wait ended.

STATE

VARCHAR2(19)

Wait state:

  • 0 - WAITING (the session is currently waiting)

  • -2 - WAITED UNKNOWN TIME (duration of last wait is unknown)

  • -1 - WAITED SHORT TIME (last wait <1/100th of a second)

  • >0 - WAITED KNOWN TIME (WAIT_TIME = duration of last wait)

SERVICE_NAME

VARCHAR2(64)

Service name of the session

SQL_TRACE

VARCHAR2(8)

Indicates whether SQL tracing is enabled (ENABLED) or disabled (DISABLED)

SQL_TRACE_WAITS

VARCHAR2(5)

Indicates whether wait tracing is enabled (TRUE) or not (FALSE)

SQL_TRACE_BINDS

VARCHAR2(5)

Indicates whether bind tracing is enabled (TRUE) or not (FALSE)

关于“如何通过操作系统的进程号查看数据库的session”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

--结束END--

本文标题: 如何通过操作系统的进程号查看数据库的session

本文链接: https://lsjlt.com/news/63809.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 如何通过操作系统的进程号查看数据库的session
    这篇文章将为大家详细讲解有关如何通过操作系统的进程号查看数据库的session,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。在工作中很多新手会遇到这种问题,就是操作系统显...
    99+
    2024-04-02
  • 如何根据操作系统进程号查看oracle对应的SQL语句内容
    这篇文章主要介绍了如何根据操作系统进程号查看oracle对应的SQL语句内容,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。 1、  ...
    99+
    2024-04-02
  • 如何通过phonegap操作数据库
    这篇文章主要介绍了如何通过phonegap操作数据库,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。实例如下:<!DOCTYPE&nbs...
    99+
    2024-04-02
  • 如何通过pycharm实现对数据库的查询等操作(非多步操作)
    目录pycharm对数据库的查询等操作(非多步操作)Pycharm操作数据库步骤服务端配置客户端配置pycharm对数据库的查询等操作(非多步操作) import pymysql i...
    99+
    2024-04-02
  • oracle数据库进程如何查看
    在Oracle数据库中,可以通过以下方法来查看进程: 使用SQL*Plus命令行工具连接到数据库。 在SQL*Plus提示符下,执...
    99+
    2024-04-09
    oracle
  • python通过远程连接mysql数据库进行操作
    文章目录 前言一、开启远程访问权限1、开启远程访问端口2、命令行登录mysql 二、Navicat 建库1、新建连接2、建库建表 三、python对数据库进行远程操作三、总结四、参考资...
    99+
    2023-09-20
    数据库 python mysql
  • 如何查看Oracle数据库的操作历史记录
    查看操作历史记录的方法:1、使用Oracle内置的审计功能,可以记录数据库中发生的各种操作,包括登录、DDL语句、DML语句等;2、使用Oracle日志文件,其中包含了数据库中发生的各种操作,可以通过查看日志文件来获取操作历史记录;3、使用...
    99+
    2023-10-22
    oracle
  • 如何通过linq语法来操作数据库
    小编给大家分享一下如何通过linq语法来操作数据库,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!首先创建一个Console Application,然后创建一个名...
    99+
    2023-06-17
  • oracle数据库如何查看存储过程
    可以通过以下步骤查看 oracle 数据库中的存储过程:1. 连接到数据库;2. 获取存储过程列表;3. 查看存储过程代码;4. 查看存储过程文档。 如何查看 Oracle 数据库中的...
    99+
    2024-04-19
    oracle
  • 如何利用Node.js查看操作系统及其版本号
    这篇文章给大家分享的是有关如何利用Node.js查看操作系统及其版本号的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。获取操作系统在 Node.js 中判断操作系统是非常简单的,用...
    99+
    2024-04-02
  • Linux操作系统 进程之间的通信
     进程之间的通信预备知识:用户态和内核态,当一个进程在执行用户自己的代码时处于用户运行态(用户态);当一个进程因为系统调用陷入内核代码中执行时处于内核运行态(内核态)。进程之间的通信(Inter Processs Communic...
    99+
    2023-06-05
  • 如何查询windows操作系统数据库的安装目录ORACLE_HOME
    这篇文章主要为大家展示了“如何查询windows操作系统数据库的安装目录ORACLE_HOME”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何查询window...
    99+
    2024-04-02
  • 分时操作系统如何处理进程之间的通信?
    引言 分时操作系统是一种多任务操作系统,允许多个进程同时在同一计算机上运行。为了使进程能够有效地交互,分时操作系统提供了一系列机制来处理进程之间的通信。这些机制对于多进程应用程序来说至关重要,它允许进程之间共享数据、同步操作并响应事件。...
    99+
    2024-03-05
    分时操作系统、进程间通信、管道、信号、共享内存、消息队列
  • 如何在MySQL中进行跨数据库的查询操作
    在MySQL中进行跨数据库的查询操作,可以使用以下两种方法: 使用全限定表名(Fully Qualified Table Name...
    99+
    2024-03-06
    MySQL
  • ubuntu如何查看执行的进程号
    ubuntu查看执行进程号的方法:1、打开终端;2、输入命令查看所有执行的进程号,根据进程名获得对应程序的进程号即可。具体操作步骤:使用快捷键【Ctrl+Alt+T】打开终端;输入以下命令查看所有执行的进程号。ps -aux #查看所有运行...
    99+
    2024-04-02
  • 如何利用C#通过sql语句操作Sqlserver数据库教程
    目录必要准备SQL语句编写加执行编写执行创建执行器ExecuteNonQuery()方式执行二者区别  ExecuteReader()方式执行实例:1-创建一张数...
    99+
    2022-11-13
    c# sql语句 c#操作sqlserver数据库 c# sqlserver
  • 如何查看MySQL数据库恢复的进度
    MySQL是一款非常常用的开源关系型数据库管理系统,它具有稳定、高效、灵活等特点,被广泛应用于各种类型的应用程序中。在使用MySQL时,不可避免地会遇到数据库的恢复操作,如何准确地查看...
    99+
    2024-02-24
    mysql恢复 查看方法 数据库进度 mysql错误
  • 通过 Linux 系统线程查找 MySQL 8.0 进程的线程
    查看 MySQL 进程 ID ps -ef | grep mysqld 查看 MySQL 的系统线程 top -Hp 14809 通过系统线程查看 MySQL 线程 select * from p...
    99+
    2024-04-02
  • 操作系统进程通信的终极解码器
    在多任务操作系统中,进程独立执行,但需要协作以完成复杂任务。进程通信是进程之间交换数据和同步操作的关键机制。 进程通信机制 共享内存:进程直接访问同一块物理内存,允许快速高效的数据交换。然而,它需要仔细的同步机制以防止冲突。 管道...
    99+
    2024-04-02
  • 操作系统进程通信中的哲学沉思
    信息传递的本质 进程通信的核心是信息传递。在最基本的层面上,信息是由比特和字节组成的序列,代表着意义。然而,信息的本质远不止于此。它承载着意图、知识和理解。当进程交换信息时,它们不仅在传递数据,还在传递想法、概念和信念。 通信机制的多样性...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作