Oracle Lock Table Processing

Source: Internet
Author: User

1. Querying for locks in the database

SELECT * from V$lock;
SELECT * from V$lock where block=1;

2. Querying for Locked objects

SELECT * from V$locked_object;

3. Query blocking

Check for blocked sessions
SELECT * from V$lock where lmode=0 and type in (' TM ', ' TX ');

Check for blocking other session locks
SELECT * from V$lock where lmode>0 and type in (' TM ', ' TX ');

4. Querying the process that the database is waiting for a lock

SELECT * from v$session where lockwait are NOT null;

5. Query the relationship between session lock waits

Select A.sid holdsid,b.sid waitsid,a.type,a.id1,a.id2,a.ctime from V$lock A,v$lock b
where A.id1=b.id1 and A.id2=b.id2 and A.block=1 and b.block=0;

6. Query the lock wait event
SELECT * from v$session_wait where event= ' enqueue ';

Solution:
Select session_id from V$locked_object; --First get the session_id of the locked object
SELECT SID, Serial#, username, osuser from v$session where sid = session_id; --Get the SID and serial# of V$session through the session_id obtained above, then terminate the process.
ALTER SYSTEM KILL SESSION ' sid,serial ';
Example
ALTER SYSTEM KILL SESSION ' 13, 8 ';

Oracle Lock Table Processing

Related Article

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.