查询每台应用服务器占用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值