`
fudehai001
  • 浏览: 490702 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

oracle v$locks和v$session的说明

阅读更多
Oracle9i Database Reference
Release 2 (9.2)
Part Number A96536-02


V$LOCK
This view lists the locks currently held by the Oracle database server and outstanding requests for a lock or latch.

Column Datatype Description
ADDR
RAW(4 | 8)
Address of lock state object

KADDR
RAW(4 | 8)
Address of lock

SID
NUMBER
Identifier for session holding or acquiring the lock

TYPE
VARCHAR2(2)
Type of user or system lock

The locks on the user types are obtained by user applications. Any process that is blocking others is likely to be holding one of these locks. The user type locks are:

TM - DML enqueue

TX - Transaction enqueue

UL - User supplied

The locks on the system types are held for extremely short periods of time. The system type locks are listed in Table 3-1.

ID1
NUMBER
Lock identifier #1 (depends on type)

ID2
NUMBER
Lock identifier #2 (depends on type)

LMODE
NUMBER
Lock mode in which the session holds the lock:

0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)

REQUEST
NUMBER
Lock mode in which the process requests the lock:

0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)

CTIME
NUMBER
Time since current mode was granted

BLOCK
NUMBER
The lock is blocking another lock


Table 3-1  Values for the TYPE Column: System Types
System Type Description System Type Description
BL
Buffer hash table instance
NA..NZ
Library cache pin instance (A..Z = namespace)

CF
Control file schema global enqueue
PF
Password File

CI
Cross-instance function invocation instance
PI, PS
Parallel operation

CU
Cursor bind
PR
Process startup

DF
Data file instance
QA..QZ
Row cache instance (A..Z = cache)

DL
Direct loader parallel index create
RT
Redo thread global enqueue

DM
Mount/startup db primary/secondary instance
SC
System commit number instance

DR
Distributed recovery process
SM
SMON

DX
Distributed transaction entry
SN
Sequence number instance

FS
File set
SQ
Sequence number enqueue

HW
Space management operations on a specific segment
SS
Sort segment

IN
Instance number
ST
Space transaction enqueue

IR
Instance recovery serialization global enqueue
SV
Sequence number value

IS
Instance state
TA
Generic enqueue

IV
Library cache invalidation instance
TS
Temporary segment enqueue (ID2=0)

JQ
Job queue
TS
New block allocation enqueue (ID2=1)

KK
Thread kick
TT
Temporary table enqueue

LA .. LP
Library cache lock instance lock (A..P = namespace)
UN
User name

MM
Mount definition global enqueue
US
Undo segment DDL

MR
Media recovery
WL
Being-written redo log instance

 


V$SESSION
This view lists session information for each current session.

Column Datatype Description
SADDR
RAW(4 | 8)
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 | 8)
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-3. 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 (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(30)
Operating system client user name

PROCESS
VARCHAR2(9)
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)
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

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

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_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 - the client is able to fail over its session following a disconnect
SELECT - the client is able to fail over queries in progress as well
See Also:

Oracle9i Database Concepts for more information on TAF
Oracle9i 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 - the client itself reconnects following a disconnect
PRECONNECT - the backup instance can support all connections from every instance for which it is backup

FAILED_OVER
VARCHAR2(3)
Indicates (YES|NO) whether the session is running in failover mode and failover has occurred

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, value is 0.

CLIENT_IDENTIFIER
VARCHAR2(64)
 

Table 3-3  COMMAND Column of V$SESSION and Corresponding Commands
Number Command Number Command
1
CREATE TABLE
2
INSERT

3
SELECT
4
CREATE CLUSTER

5
ALTER CLUSTER
6
UPDATE

7
DELETE
8
DROP CLUSTER

9
CREATE INDEX
10
DROP INDEX

11
ALTER INDEX
12
DROP TABLE

13
CREATE SEQUENCE
14
ALTER SEQUENCE

15
ALTER TABLE
16
DROP SEQUENCE

17
GRANT OBJECT
18
REVOKE OBJECT

19
CREATE SYNONYM
20
DROP SYNONYM

21
CREATE VIEW
22
DROP VIEW

23
VALIDATE INDEX
24
CREATE PROCEDURE

25
ALTER PROCEDURE
26
LOCK

27
NO-OP
28
RENAME

29
COMMENT
30
AUDIT OBJECT

31
NOAUDIT OBJECT
32
CREATE DATABASE LINK

33
DROP DATABASE LINK
34
CREATE DATABASE

35
ALTER DATABASE
36
CREATE ROLLBACK SEG

37
ALTER ROLLBACK SEG
38
DROP ROLLBACK SEG

39
CREATE TABLESPACE
40
ALTER TABLESPACE

41
DROP TABLESPACE
42
ALTER SESSION

43
ALTER USER
44
COMMIT

45
ROLLBACK
46
SAVEPOINT

47
PL/SQL EXECUTE
48
SET TRANSACTION

49
ALTER SYSTEM
50
EXPLAIN

51
CREATE USER
52
CREATE ROLE

53
DROP USER
54
DROP ROLE

55
SET ROLE
56
CREATE SCHEMA

57
CREATE CONTROL FILE
59
CREATE TRIGGER

60
ALTER TRIGGER
61
DROP TRIGGER

62
ANALYZE TABLE
63
ANALYZE INDEX

64
ANALYZE CLUSTER
65
CREATE PROFILE

66
DROP PROFILE
67
ALTER PROFILE

68
DROP PROCEDURE
70
ALTER RESOURCE COST

71
CREATE SNAPSHOT LOG
72
ALTER SNAPSHOT LOG

73
DROP SNAPSHOT LOG
74
CREATE SNAPSHOT

75
ALTER SNAPSHOT
76
DROP SNAPSHOT

77
CREATE TYPE
78
DROP TYPE

79
ALTER ROLE
80
ALTER TYPE

81
CREATE TYPE BODY
82
ALTER TYPE BODY

83
DROP TYPE BODY
84
DROP LIBRARY

85
TRUNCATE TABLE
86
TRUNCATE CLUSTER

91
CREATE FUNCTION
92
ALTER FUNCTION

93
DROP FUNCTION
94
CREATE PACKAGE

95
ALTER PACKAGE
96
DROP PACKAGE

97
CREATE PACKAGE BODY
98
ALTER PACKAGE BODY

99
DROP PACKAGE BODY
100
LOGON

101
LOGOFF
102
LOGOFF BY CLEANUP

103
SESSION REC
104
SYSTEM AUDIT

105
SYSTEM NOAUDIT
106
AUDIT DEFAULT

107
NOAUDIT DEFAULT
108
SYSTEM GRANT

109
SYSTEM REVOKE
110
CREATE PUBLIC SYNONYM

111
DROP PUBLIC SYNONYM
112
CREATE PUBLIC DATABASE LINK

113
DROP PUBLIC DATABASE LINK
114
GRANT ROLE

115
REVOKE ROLE
116
EXECUTE PROCEDURE

117
USER COMMENT
118
ENABLE TRIGGER

119
DISABLE TRIGGER
120
ENABLE ALL TRIGGERS

121
DISABLE ALL TRIGGERS
122
NETWORK ERROR

123
EXECUTE TYPE
157
CREATE DIRECTORY

158
DROP DIRECTORY
159
CREATE LIBRARY

160
CREATE JAVA
161
ALTER JAVA

162
DROP JAVA
163
CREATE OPERATOR

164
CREATE INDEXTYPE
165
DROP INDEXTYPE

167
DROP OPERATOR
168
ASSOCIATE STATISTICS

169
DISASSOCIATE STATISTICS
170
CALL METHOD

171
CREATE SUMMARY
172
ALTER SUMMARY

173
DROP SUMMARY
174
CREATE DIMENSION

175
ALTER DIMENSION
176
DROP DIMENSION

177
CREATE CONTEXT
178
DROP CONTEXT

179
ALTER OUTLINE
180
CREATE OUTLINE

181
DROP OUTLINE
182
UPDATE INDEXES

183
ALTER OPERATOR
 

 

 

 

Oracle9i Database Performance Tuning Guide and Reference
Release 2 (9.2)
Part Number A96533-02

V$LOCK
This view has a row for every lock held or requested on the system. You should examine this view if you find sessions waiting for the wait event enqueue. If you find sessions waiting for a lock, then the sequence of events could be the following:

Use V$LOCK to find the sessions holding the lock.
Use V$SESSION to find the SQL statements being executed by the sessions holding the lock and waiting for the lock.
Use V$SESSION_WAIT to find what the session holding the lock is blocked on.
Use V$SESSION to get more details about the program and user holding the lock.
Useful Columns for V$LOCK
SID: Identifier of the session holding/requesting the lock
TYPE: Type of lock
LMODE: Lock mode in which the session holds the lock
REQUEST: Lock mode in which the session requests the lock
ID1, ID2: Lock resource identifiers
Common Lock Types
Several common locks are described in this section.

TX: Row Transaction Lock
This lock is required in exclusive mode (mode 6) to change data.
One lock is acquired for each active transaction. It is released when the transaction ends due to a commit or rollback.
If a block containing the row(s) to be changed does not have any ITL (interested transaction list) entries left, then the session requests the lock in shared mode (mode 4). It is released when the session gets an ITL entry for the block.
If any of the rows to be changed are locked by another session, then locking session's transaction lock is requested in exclusive mode. When the locking transaction ends, this request ends, and the rows are covered under the requesting session's existing TX lock.
The lock points to the rollback segment and transaction table entries for the transaction.
Do the following to avoid contention on this enqueue:

To avoid contention on TX-6 enqueues, review the application.
To avoid contention on TX-4 enqueues, consider increasing INITRANS for the object.
TM: DML Lock
This lock is required in exclusive mode for executing any DDL statements on a database object; for example, lock table in exclusive mode, alter table, drop table.
This lock is also acquired in shared mode when executing DML statements such as INSERT, UPDATE, or DELETE. This prevents other sessions from executing a DDL statement on the same object concurrently.
For every object whose data is being changed, a TM lock is required.
The lock points to the object.
To avoid contention on TM enqueues, consider disabling the table lock for the object. Disabling the table lock prevents any DDL from executing on the object.

ST - Space Transaction Lock
There is only one lock for each database (not instance).
This lock is required in exclusive mode for any space management activity (creation or dropping any extents) except with locally managed tablespaces.
Object creation, dropping, extension, and truncation all serialize on this lock.
Most common causes for contention on this lock are sorting to disk (not using true temporary tablespaces) or rollback segment extension and shrinking.
Do the following to avoid contention on this enqueue:

Use true temporary tablespaces, utilizing tempfiles. Temporary segments are not created and dropped after every sort to disk.
Use locally managed tablespaces
Size rollback segments to avoid dynamic extension and shrinking, or use automatic undo management.
Avoid application practices that create and drop database objects.
UL - User Defined Locks
Users can define their own locks.

See Also:
Oracle9i Database Concepts for more information on locks


Common Modes for Request/Lmode
0: None
2: Row Share: used for shared DML locks
4: Share: used for shared TX when waiting for ITL entry
6: Exclusive used for row level, DML locks
Any row in V$LOCK either has LMODE=0 (indicating it is a request) or REQUEST=0 (indicating it is a held lock).

Resource Identifier ID1
For DML locks, ID1 is the object_id.

For TX locks, ID1 points to the rollback segment and transaction table entry.

Join Columns for V$LOCK
Table 24-8 lists the join columns for V$LOCK.

Table 24-8 Join Columns for V$LOCK
Column View Joined Column(s)
SID
V$SESSION
SID

ID1, ID2, TYPE
V$LOCK
ID1, ID2, TYPE

ID1
DBA_OBJECTS
OBJECT_ID

TRUNCID1/65536)
V$ROLLNAME
USN


This is used to find the session holding the lock, if a session is waiting for a lock.
This can be used to find the locked object for DML locks (type = `TM').
This can be used to find the rollback segment in use for row transaction locks (TYPE = `TX'). However, a less cryptic join might be through V$TRANSACTION.
Example 24-11 Finding the Sessions Holding the Lock
Find the (ID1, ID2, type) for sessions waiting for a lock (LMODE=0).

Find the session holding the lock (REQUEST=0) for that ID1, ID2, type.

SELECT lpad(' ',DECODE(request,0,0,1))||sid sess, id1, id2, lmode, request, type
FROM V$LOCK
WHERE id1 IN (SELECT id1 FROM V$LOCK WHERE lmode = 0)
ORDER BY id1,request

SID          ID1        ID2      LMODE    REQUEST TY
------ ---------- ---------- ---------- ---------- --
1237       196705     200493          6          0 TX <- Lock Holder
1256      196705     200493          0          6 TX <- Lock Waiter
1176      196705     200493          0          6 TX <- Lock Waiter
938        589854     201352          6          0 TX <- Lock Holder
1634      589854     201352          0          6 TX <- Lock Waiter

Example 24-12 Finding the Statements being Executed by These Sessions
SELECT sid, sql_hash_value
FROM V$SESSION
WHERE SID IN (1237,1256,1176,938,1634);

SID  SQL_HASH_VALUE
-----  --------------
  938      2078523611 <-Holder
1176      1646972797 <-Waiter
1237      3735785744 <-Holder
1256      1141994875 <-Waiter
1634      2417993520 <-Waiter

Example 24-13 Finding the Text for These SQL Statements
HASH_VALUE SQL_TEXT
---------- ----------------------------------------------------------------
1141994875 SELECT TO_CHAR(CURRENT_MAX_UNIQUE_IDENTIFIER + 1 )   FROM PO_UNI
           QUE_IDENTIFIER_CONTROL  WHERE TABLE_NAME = DECODE(:b1,'RFQ','PO_
           HEADERS_RFQ','QUOTATION','PO_HEADERS_QUOTE','PO_HEADERS') FOR UP
           DATE OF CURRENT_MAX_UNIQUE_IDENTIFIER
1646972797 SELECT TO_CHAR(CURRENT_MAX_UNIQUE_IDENTIFIER + 1 )   FROM PO_UNI
           QUE_IDENTIFIER_CONTROL  WHERE TABLE_NAME = 'PO_HEADERS'  FOR UPD
           ATE OF CURRENT_MAX_UNIQUE_IDENTIFIER
2078523611 select CODE_COMBINATION_ID,  enabled_flag,  nvl(to_char(start_da
           te_active, 'J'), -1),  nvl(to_char(end_date_active, 'J'), -1), S
           EGMENT2||'.'||SEGMENT1||'.'||||SEGMENT6,detail_posting_allowed_f
           lag,summary_flag  from GL_CODE_COMBINATIONS  where CHART_OF_ACCO
           UNTS_ID = 101  and SEGMENT2 in ('000','341','367','388','389','4
           52','476','593','729','N38','N40','Q21','Q31','U21')  order by S
           EGMENT2, SEGMENT1, SEGMENT6
2417993520 select 0 into :b0  from pa_projects where project_id=:b1 for upd
           ate
3735785744 begin 0 := FND_ATTACHMENT_UTIL_PKG.GET_ATCHMT_EXISTS(_ENTITY
           _NAME, _PKEY1, _PKEY2, :L_PKEY3, :L_PKEY4, :L_PKEY5, :L_FUNC
           TION_NAME, :L_FUNCTION_TYPE); end;


The locked sessions' statements show that the sessions 1176 and 1256 are waiting for a lock on the PO_UNIQUE_IDENTIFIER_CONTROL held by session 1237, while session 1634 is waiting for a lock on PA_PROJECTS held by session 938. Query V$SESSION_WAIT, V$SESSION, and V$SESSION_EVENT to get more details about the sessions and users. For example:

Who is holding the lock?
Is the session holding the lock active or idle
Is the session executing long running queries while holding the lock


V$SESSION
This view has one row for every session connected to the database instance. The sessions include user sessions, as well as background processes like DBWR, LGWR, archiver.

See Also:
Oracle9i Database Concepts


Useful Columns for V$SESSION
V$SESSION is basically an information view used for finding the SID or SADDR of a user. However, it has some columns that change dynamically and are useful for examining a user. For example:

SQL_HASH_VALUE, SQL_ADDRESS: These identify the SQL statement currently being executed by the session. If NULL or 0, then the session is not executing any SQL statement. PREV_HASH_VALUE and PREV_ADDRESS identify the previous statement being executed by the session.


--------------------------------------------------------------------------------
Note:
When selecting from SQL*Plus, make sure that you have the column defined with adequate width (11 numbers wide) to see the complete number.

--------------------------------------------------------------------------------


STATUS: This column identifies if the session is:

Active: executing a SQL statement (waiting for/using a resource)
Inactive: waiting for more work (that is, SQL statements)
Killed: marked to be killed
The following columns provide information about the session and can be used to find a session when a combination (one or more) of the following are known:

Session Information
SID: Session identifier, used to join to other columns
SERIAL#: Counter, which is incremented each time a SID is reused by another session (when a session ends and another session starts and uses the same SID)
AUDSID: Auditing session ID uniquely identifies a session over the life of a database. It is also useful when finding the parallel query slaves for a query coordinator (during the PQ execution they have the same AUDSID)
USERNAME: The Oracle user name for the connected session
Client Information
The database session is initiated by a client process that could be running on the database server or connecting to the database across SQL*Net from a middle tier server or even a desktop. The following columns provide information about this client process:

OSUSER: Operating system user name for the client process
MACHINE: Machine where the client process is executing
TERMINAL: Terminal (if applicable) where the client process is running
PROCESS: Process ID of the client process
PROGRAM: Client program being executed by the client process
To display TERMINAL, OSUSER for users connecting from PCs, set the keys TERMINAL, USERNAME in ORACLE.INI or the Windows registry on their PCs if they are not showing up by default.

Application Information
Call the package DBMS_APPLICATION_INFO to set some information to identify the user. This shows up in the following columns:

CLIENT_INFO: Set in DBMS_APPLICATION_INFO
ACTION: Set in DBMS_APPLICATION_INFO
MODULE: Set in DBMS_APPLICATION_INFO
The following V$SESSION columns are also useful:

ROW_WAIT_OBJ#
ROW_WAIT_FILE#
ROW_WAIT_BLOCK#
ROW_WAIT_ROW#
Join Columns for V$SESSION
Table 24-16 is a list of several columns that can be used to join to other fixed views.

Table 24-16 Join Columns for V$SESSION
Column View Joined Column(s)
SID
V$SESSION_WAIT, V$SESSTAT, V$LOCK, V$SESSION_EVENT, V$OPEN_CURSOR
SID

(SQL_HASH_VALUE, SQL_ADDRESS)
V$SQLTEXT, V$SQLAREA, V$SQL
(HASH_VALUE, ADDRESS)

(PREV_HASH_VALUE, PREV_SQL_ADDRESS)
V$SQLTEXT, V$SQLAREA, V$SQL
(HASH_VALUE, ADDRESS)

TADDR
V$TRANSACTION
ADDR

PADDR
V$PROCESS
ADDR


Example 24-21 Finding Your Session
SELECT SID, OSUSER, USERNAME, MACHINE, PROCESS
  FROM V$SESSION
WHERE audsid = userenv('SESSIONID');

  SID OSUSER     USERNAME    MACHINE     PROCESS
----- ---------- ----------- ----------- --------
  398 amerora    PERFSTAT    rgmdbs1     26582

Example 24-22 Finding a Session When the Machine Is Known
SELECT SID, OSUSER, USERNAME, MACHINE, TERMINAL
  FROM V$SESSION
WHERE terminal = 'pts/tl'
   AND machine  = 'rgmdbs1';

SID OSUSER    USERNAME  MACHINE    TERMINAL
---- --------- --------- ---------- ----------
398 amerora   PERFSTAT  rgmdbs1    pts/tl

Example 24-23 Finding the SQL Statement Currently Being Run by a Session
It is a common requirement to find the SQL statement currently being executed by a given session. If a session is experiencing or responsible for a bottleneck, then the statement explains what the session might be doing.

col hash_value form 99999999999
SELECT sql_hash_value hash_value
  FROM V$SESSION WHERE sid = 406;

HASH_VALUE
----------
4249174653
SQL> /

HASH_VALUE
----------
4249174653
SQL> /

HASH_VALUE
----------
4249174653
SQL> /

HASH_VALUE
----------
4249174653


This example waited for five seconds, executed the statement again, and repeated the action couple of times. The same hash_value comes up again and again, indicating that the statement is being executed by the session. As a next step, find the statement text using the view V$SQLTEXT and statement statistics from V$SQLAREA.
分享到:
评论

相关推荐

    ORACLE数据库日常维护手册.doc

    可以使用SELECT语句检查等待事件,例如:SELECT SID, A.USERNAME, EVENT, WAIT_CLASS, T1.SQL_TEXT FROM V$SESSION A, V$SQLAREA T1 WHERE WAIT_CLASS &lt;&gt; 'Idle' AND A.SQL_ID = T1.SQL_ID;这条语句将返回当前等待...

    ORACLE9i_优化设计与系统调整

    §7.1 应用系统环境规划和Oracle系统安装考虑 91 §7.1.1 操作系统安装考虑 91 §7.1.2 Oracle系统安装考虑 92 §7.2 关于创建多个Oracle实例问题 93 §7.3 Oracle系统安装后的优化基础工作 94 §7.3.1 Oracle系统...

    Oracle9i的init.ora参数中文说明

    Oracle9i初始化参数中文说明 Blank_trimming: 说明: 如果值为TRUE, 即使源长度比目标长度 (SQL92 兼容) 更长, 也允许分配数据。 值范围: TRUE | FALSE 默认值: FALSE serializable: 说明: 确定查询是否获取表级...

    oracle查看会话锁定的所有对象代码分享

    代码如下:select session_id sid, owner, name, type, mode_held... 您可能感兴趣的文章:ORACLE 查询被锁住的对象,并结束其会话的方法解析Oracle数据库中的对象集合schemaORACLE 常用的SQL语法和数据对象Oracle使用PL/

    oracle学习文档 笔记 全面 深刻 详细 通俗易懂 doc word格式 清晰 连接字符串

    oracle建议用户自己设计数据库管理和安全的权限规划,而不要简单的使用这些预定角色。将来的版本中这些角色可能不会作为预定义角色。  DELETE_CATALOG_ROLE, EXECUTE_CATALOG_ROLE,SELECT_CATALOG_ROLE这些角色...

    最完整的Toad For Oracle使用手册

    Toad and Oracle Enterprise Manager 29 Quick Search Bar 30 Additional Resources 31 Working with other Quest Products 32 Knowledge Xpert 32 Using SQL Optimizer with Toad 32 Benchmark Factory 33 Quest ...

    oracle优化大全

    Cursor & SQL Processing.doc Data Dictionary.doc Disk & IO.doc Full Table Scans.doc General.doc Hit&Miss Ratios.doc Locks.doc Miscellaneous.doc Objects.doc Partitions.doc ...Oracle SQL 性能优化.doc

    ORACLE锁机制深入理解

    数据库是一个多用户使用... 在数据库中有两种基本的锁类型:排它锁(Exclusive Locks,即X锁)和共享锁(Share Locks,即S锁)。当数据对象被加上排它锁时,其他的事务不能对它读取和修改。加了共享锁的数据对象可以被

    Oracle数据库”记录被另一个用户锁住”解决方法(推荐)

    1、先来看看为什么会出锁住:  数据库是一个多用户使用的共享资源。... 在数据库中有两种基本的锁类型:排它锁(Exclusive Locks,即X锁)和共享锁(Share Locks,即S锁)。当数据对象被加上排它锁时,其

    JAVA面试题最全集

    简述synchronized和java.util.concurrent.locks.Lock的异同 ? 34.EJB规范规定EJB中禁止的操作有哪些? 35.java除了8种基本类型外,在虚拟机里还有哪一种,有什么作用? 36.除了使用new关键字创建对象意外,试列举...

    java面试题

    39. 解释$ORACLE_HOME 和$ORACLE_BASE的区别? 19 40. session与cookie的区别和联系? 19 41. Statement和PrepareStatement的区别 19 42. JSP的内置对象及方法。 19 43. JSP的常用指令 20 44. 四种会话跟踪技术 20 45...

    千方百计笔试题大全

    77、简述synchronized和java.util.concurrent.locks.Lock的异同 ? 18 78、abstract class Name { private String name; public abstract boolean isStupidName(String name) {}}这有何错误? 18 79、public class ...

    java面试宝典

    77、简述synchronized和java.util.concurrent.locks.Lock的异同 ? 18 78、abstract class Name { private String name; public abstract boolean isStupidName(String name) {}}这有何错误? 18 79、public class ...

    超级有影响力霸气的Java面试题大全文档

    并说出SessionBean和EntityBean的区别,StatefulBean和StatelessBean的区别。 EJB包括Session Bean、Entity Bean、Message Driven Bean,基于JNDI、RMI、JAT等技术实现。 SessionBean在J2EE应用程序中被用来完成...

    java 面试题 总结

    并说出SessionBean和EntityBean的区别,StatefulBean和StatelessBean的区别。 EJB包括Session Bean、Entity Bean、Message Driven Bean,基于JNDI、RMI、JAT等技术实现。 SessionBean在J2EE应用程序中被用来完成...

    java基础题 很全面

    50. 简述synchronized和java.util.concurrent.locks.Lock的异同 ? 13 51. 排序都有哪几种方法?请列举。用JAVA实现一个快速排序。 13 52. JAVA语言如何进行异常处理,关键字:throws,throw,try,catch,finally分别代表...

    最新Java面试宝典pdf版

    9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...

    Java面试笔试资料大全

    9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...

    Java面试宝典2010版

    54、简述synchronized和java.util.concurrent.locks.Lock的异同 ? 55、设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。 56、子线程循环10次,接着主线程循环100,接着又回到子线程...

Global site tag (gtag.js) - Google Analytics