Oracle database query lock table and unlock statement

Source: Internet
Author: User

Query Lock Table statement

The code is as follows Copy Code

SELECT A.owner scheme name,
A.object_name table name,
B.XIDUSN rollback segment number,
B.xidslot slot number,
B.XIDSQN serial number,
b.session_id Lock Table session_id,
B.oracle_username Lock table user name,
Decode (D.type,
' XR ',
' NULL ',
' RS ',
' SS (row-s) ',
' CF ',
' SS (row-s) ',
' TM ',
' TABLE LOCK ',
' PW ',
' TABLE LOCK ',
' To ',
' TABLE LOCK ',
' TS ',
' TABLE LOCK ',
' RT ',
' ROW LOCK ',
' TX ',
' ROW LOCK ',
' MR ',
' S (Share) ',
NULL) Locking method,
C.machine User Group,
C.terminal machine Name,
B.os_user_name System User Name,
b.process System process ID,
DECODE (c.status, ' INACTIVE ', ' inactive ', ' active ', ' activity ') activities,
C.server,
C.sid,
c.serial#,
C.program connection mode,
C.logon_time
From All_objects A, V$locked_object B, SYS. Gv_$session C, V$lock D
WHERE (a.object_id = b.object_id)
and (b.process = c.process)
and C.sid = D.sid
and B.locked_mode = D.lmode
Order by 1, 2;

Example 2

Query-locked tables:

The code is as follows Copy Code

SELECT l.session_id Sid, S.serial#, L.locked_mode,l.oracle_username,

L.os_user_name,s.machine, S.terminal, O.object_name, S.logon_time

From V$locked_object L, all_objects O, v$session s

WHERE l.object_id = o.object_id

and l.session_id = S.sid

Order by Sid, S.serial#;

And remove this record from the system lock.

Example 1

The code is as follows Copy Code

ALTER System KILL Session ' sid,serial# ';

If multiple SIDs and serial# delete each record repeatedly

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.