How to see if a table is locked and how to unlock it in Oracle

Source: Internet
Author: User

--1, the following are related tables
SELECT * from V$lock;
SELECT * from V$sqlarea;
SELECT * from V$session;
SELECT * from V$process;
SELECT * from V$locked_object;
SELECT * from All_objects;
SELECT * from v$session_wait;

--2, viewing locked tables
Select B.owner,b.object_name,a.session_id,a.locked_mode from V$locked_object a,dba_objects b where b.object_id = a.object_id;

--3, look at that user, that process, as a deadlock.
Select B.username,b.sid,b.serial#,logon_time from V$locked_object a,v$session b where a.session_id = B.sid ORDER by B.logo N_time;

--4, viewing a connected process
SELECT SID, Serial#, username, osuser from v$session;

--5, sid Isolated, Serial#,os_user_name, machine_name, terminal, lock Type,mode
SELECT S.sid, s.serial#, S.username, S.schemaname, S.osuser, s.process, S.machine,
S.terminal, S.logon_time, L.type
From V$session S, V$lock l
WHERE S.sid = L.sid
And S.username is not NULL
ORDER by Sid;

This statement will find the locks generated by all DML statements in the database, and can also be found
Any DML statement actually produces two locks, one is a table lock and one is a row lock.

--6, kill the process sid,serial#
Alter system kill session ' 210,11562 ';

How to see if a table is locked and how to unlock it in Oracle

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.