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.