View Oracle Database Table locked instance Fault Locating

Source: Internet
Author: User
View the oracle database table lock example mdash; fault locating 1. Open a session session1 (actually, establish a connection with the database, you can use third-party software

View the oracle database table lock example mdash; fault locating 1. Open a session session1 (actually, establish a connection with the database, you can use third-party software

View Oracle Database Table lock example-Fault Locating

1. Start a session session1 (actually, you can establish a connection with the database through a third-party software or directly use sqlplus)

SQL> select sid from v $ mystat where rownum = 1;

SID

158

SQL> create table t (x int primary key );

Table created

SQL> insert into t values (1 );

Commit;

SQL> update t1 set t = 10 where x = 1;

A row has been updated;

2. Start another session

SQL> select sid from v $ mystat where rowunm = 1;

SID

157

SQL> update t1 se x = 10 where x = 1;

Session2 is locked by session1 at this time.

You can view the lock information in the v $ ock view.

SQL> select sid, type, id1, id2, LMODE, request, block from v $ lock where sid in (157,158) order by sid;

Sid ty id1 id2 lmode request block

157 TM 51349 0 3 0 0

157 TX 327699 292 0 6 0

158 TX 327699 292 6 0 1

158 TM 51349 0 3 0 1

Sid = 158 indicates the First Session, sid = 157 indicates the second session, and block = 1 indicates that the session is blocking other sessions.

Request = 6 indicates that the current session is waiting for a lock with LMODE = 6. This indicates that the session is being blocked. If this column is not 0, it is waiting for a lock.

TX row-Level Lock

TM table lock

Id1 and id2 define lock-related information. The lock mode is determined by lmode.

In general, if the system runs normally, it will suddenly stop, and most of them will be blocked (blcoked)

3. determine the user information.

SQL> select machine from v $ session where sid in (158,157)

The user's machine name is displayed.

If the user is connected through middleware, The Machine name is the name of the middleware server, and the user may need to be determined by the connection information provided by the middleware server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.