In-depth discussion: how to query users of the positive lock table in Oracle and how to release the locked table

Source: Internet
Author: User

You can use the following SQL statement in PL/SQL to query which tables in the current database are locked and which users are locking these tables:

SELECT
A. OWNER, -- user to which the OBJECT belongs
A. OBJECT_NAME, -- OBJECT Name (table name)
B. XIDUSN,
B. XIDSLOT,
B. XIDSQN,
B. SESSION_ID, -- lock the table user's session
B. ORACLE_USERNAME, -- Oracle username of the table lock user
B. OS _USER_NAME, -- lock table user's operating system login Username
B. PROCESS,
B. LOCKED_MODE,
C. MACHINE, -- lock table user's computer name (for example, WORKGROUP \ UserName)
C. STATUS, -- lock Table STATUS
C. SERVER,
C. SID,
C. SERIAL #,
C. PROGRAM-database management tools used by table lock users (for example, ob9.exe)
FROM
ALL_OBJECTS,
V $ LOCKED_OBJECT B,
SYS. GV _ $ SESSION C
WHERE
A. OBJECT_ID = B. OBJECT_ID
And B. PROCESS = C. PROCESS
Order by 1 and 2 can be used to kill the items in the current lock table at the same time BY the following command:

Alter system kill session 'sid, serial #'
-- For example: alter system kill session '201801025'

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.