`
desert3
  • 浏览: 2159543 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

查询每台应用服务器占用oracle数据库会话情况和v$session视图

阅读更多

查询每台应用服务器占用oracle数据库会话情况

select machine, count(*) c from v$session group by machine order by c desc;

 

根据机器名查询该机器发出的所有会话

select t.STATE,t.* from v$session  t where t.MACHINE like '%computername%'

 

查询当前数据库连接会话中正在等待资源或者事件的信息

select * from v$session_wait

 

通过sid或者session对应的完整sql

select sql_text from v$sqltext a where a.hash_value = (select sql_hash_value from v$session b where b.sid = '&sid'    )
order by piece asc

 

#查看某个表的索引

select index_name,index_type from user_indexes where table_name = '&tableName'

 

 

中断回话
ALTER SYSTEM KILL SESSION 'SID,SERIAL#';

 

plsql 命令窗口中用desc v$session可以查看到表结构

 

比较有用的v$session字段定义:

SADDR Session地址

SID SessionID

SERIAL#  Session序列号

USER#  使用的oracle 用户名对应的id

USERNAME 使用的oracle用户名

LOCKWAIT  锁的状态

STATUS 会话状态 ACTIVE , INACTIVE, KILLED, CACHED , SNIPED 

OSUSER 用户操作系统的登录名

MACHINE 用户的机器名

 

v$session表每个字段的意义:
$SESSION
This view lists session information for each current session.

Column   Datatype   Description  
SADDR 
RAW(4) 
Session address 

SID 
NUMBER 
Session identifier 

SERIAL# 
NUMBER 
Session serial number. Used to identify uniquely 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) 
Address of the process that owns this 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 3-7 

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 4Byte value. The low-order 2Bytes 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 (currently executing SQL), INACTIVE, KILLED (marked to be killed), CACHED (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(15) 
Operating system client user name 

PROCESS 
VARCHAR2(9) 
Operating system client process ID 

MACHINE 
VARCHAR2(64) 
Operating system machine name 

TERMINAL 
VARCHAR2(10) 
Operating system terminal name 

PROGRAM 
VARCHAR2(48) 
Operating system program name 

TYPE 
VARCHAR2(10) 
Session type 

SQL_ADDRESS 
RAW(4) 
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 

MODULE 
VARCHAR2(48) 
Contains the name of the currently executing module as set by calling the DBMS_APPLICATION_INFO.SET_MODULE procedure 

MODULE_HASH 
NUMBER 
The hash value of the above MODULE 

ACTION 
VARCHAR2(32) 
Contains the name of the currently executing action as set by calling the
DBMS_APPLICATION_INFO.SET_ACTION procedure 

ACTION_HASH 
NUMBER 
The 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 ROWID specified in ROW_WAIT_ROW# 

ROW_WAIT_FILE# 
NUMBER 
Identifier for the datafile containing the ROWID specified in ROW_WAIT_ROW#. 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 

ROW_WAIT
_BLOCK# 
NUMBER 
Identifier for the block containing the ROWID specified in ROW_WAIT_ROW#. 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 

ROW_WAIT_ROW# 
NUMBER 
The current ROWID 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 
The last call 

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. 

PDML_ENABLED 
VARCHAR2(3) 
This column has been replaced by PDML_ENABLED and PDML_STATUS. See above. 

FAILOVER_TYPE 
VARCHAR2(10) 
NONE if failover is disabled for this session, SESSION if client is able to failover its session following a disconnect, and SELECT if client is able to fail over selects in progress as well 

FAILOVER
_METHOD 
VARCHAR2(3) 
NONE if failover is disabled for this session, BASIC if client reconnects following a disconnect, PRECONNECT if the backup instance is able to support all connections from every instance that it is backup for 

FAILED_OVER 
VARCHAR2(13) 
TRUE if running in failover mode and have failed over, otherwise FALSE 

RESOURCE_CONSUMER_GROUP 
VARCHAR2(32) 
Name of the session's current resource consumer group

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

引用:http://xubin-8880-163-com.iteye.com/blog/451640

分享到:
评论

相关推荐

    oraclev$sessionv$session_wait用途详解

    在Oracle数据库管理与优化的过程中,`v$session`与`v$session_wait`视图扮演着至关重要的角色,它们提供了关于当前活动会话及其等待事件的详细信息,这对于诊断性能问题、理解数据库行为以及进行有效的资源管理至关...

    oracle_v$session_v$session_wait用途详解

    Oracle 数据库提供了大量的动态性能视图(Dynamic Performance Views),其中 `V$SESSION` 和 `V$SESSION_WAIT` 是两个非常重要的视图,它们能够帮助数据库管理员深入了解当前会话的状态以及等待事件的信息。...

    oracle 动态性能视图 (x$, v$, gv$, v_$, gv_$)

    V$视图包括了如`V$SESSION`(会话信息)、`V$DATABASE`(数据库信息)、`V$PARAMETER`(参数设置)等,覆盖了数据库性能监控、资源管理、配置设置等多个方面。V$视图通过公共同义词(Public Synonym)前缀为V$的形式...

    oracle 动态性能(V$)视图

    Oracle动态性能(V$)视图是Oracle数据库管理系统中极为重要的组成部分,它们提供了实时的数据库运行信息,帮助DBA(数据库管理员)监控、诊断和优化数据库性能。这些视图以V$开头,通常由一系列的数据字典视图组成,...

    oracle 查看当前会话执行的sql语句

    这里使用了`sql_hash_value`字段来关联`v$session`和`v$sqltext`两个视图,其中`&sid`是一个输入参数,代表了要查询的会话的SID。`order by piece asc`是为了按照SQL语句的片段顺序排列。 #### 3. 监控当前会话的...

    Oracle v$bh 视图 详细讲解

    总结,`v$bh`视图是Oracle DBA进行性能调优的重要工具,通过对缓冲区缓存的深入理解和监控,能够有效地提升数据库系统的整体性能和稳定性。通过学习和实践,你可以更好地掌握这个视图,并应用于日常的数据库管理和...

    Oracle数据库连接与会话

    如果关闭autotrace,SQL*Plus将终止第二个会话并不再监视v$session视图。 Oracle数据库连接与会话是两个紧密相连的概念,但它们之间存在一定的区别。理解它们之间的关系对于Oracle数据库管理系统的正确使用非常重要...

    Oracle性能视图学习大全

    同时,结合`V$SESSION`和`V$SESS_IO`视图,可以进一步分析特定会话的资源消耗情况。 6. **识别锁定问题**:使用`V$LOCK`和`V$SESSION`视图可以帮助识别锁定问题,并且可以根据需要关闭相关会话以解决冲突。 7. **...

    oracle中已killed session的处理

    在Oracle数据库管理中,有时会遇到一些异常情况,比如某个Session长时间未响应或占用大量资源,这时可能需要管理员手动干预,通过`ALTER SYSTEM KILL SESSION 'SID,SERIAL#'`命令来强制终止这个Session。然而,在...

    ORACLE 动态性能视图详解

    这些视图,以`V$`前缀标识,是由数据库服务器实时维护的,它们提供了关于数据库运行状况的详细信息,帮助DBA(数据库管理员)进行性能优化、故障排查等工作。由于这些视图的内容与性能紧密相关,因此它们会随着...

    有效关闭Oracle死锁进程,和释放状态为killed的session

    在Oracle数据库管理中,处理死锁进程和释放状态为killed的session是一项关键技能,尤其对于维护数据库性能和稳定性至关重要。以下将详细阐述如何通过一系列步骤有效地关闭Oracle死锁进程,以及如何释放状态为killed...

    Oracle动态性能视图

    **Oracle动态性能视图**是一组预定义的视图,用于显示Oracle数据库的内部状态和活动信息。这些视图对于DBA(数据库管理员)来说非常重要,可以帮助他们监控数据库性能、诊断问题并进行调优。 #### 二、Oracle动态...

    oracle九大性能视图

    `V$SESSION_WAIT`视图提供了每个会话正在等待的资源信息,这对于诊断会话阻塞等问题非常有帮助。 ##### 示例 ```sql SELECT EVENT, COUNT(*) FROM V$SESSION_WAIT GROUP BY EVENT ORDER BY COUNT(*) DESC; ``` 此...

    常用oracle动态性能视图

    V$SESSION 视图是 Oracle 提供的核心性能监视视图之一,它记录了所有与数据库实例建立连接的会话(session)信息,包括用户会话和后台进程,如 DBWR(数据库写进程)、LGWR(日志写进程)和归档进程等。通过 V$...

    oracle10g_V$_View & asm

    例如,V$SESSION视图提供了当前活跃会话的信息,V$INSTANCE视图显示了数据库实例的详细配置,而V$WAITSTAT则可以帮助分析系统的等待事件,从而定位性能瓶颈。 在"oracle10g_V$_Views.pdf"中,可能包含了对Oracle 10...

    通过动态参数视图分解ORACLE数据库.pdf

    例如,V$SESSION视图可以提供当前连接会话的信息,这对于诊断性能问题、追踪用户活动或进行资源管理十分有用。V$PGA_AGGREGATE_TARGET和V$SGA_TARGET等视图则帮助管理员管理共享全局区(SGA)和程序全局区(PGA)的...

    Oracle数据库管理员经常使用的表和视图

    ### Oracle数据库管理员经常使用的表和视图 在Oracle数据库管理工作中,熟练掌握并利用系统提供的数据字典表和动态性能视图(Dynamic Performance Views)对于提高数据库管理效率、确保数据库健康运行至关重要。...

Global site tag (gtag.js) - Google Analytics