Oracle Lock Processing Scripts

Source: Internet
Author: User

----Handle Deadlock processes
--View 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;

--View the user who locked the table
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.logon_time;

--Handling lock process
Alter system kill session ' sid,serial# ';

--if there is a ora-00031 error, add immediate in the back

Alter system kill session ' sid,serial# ' immediate;


Select Username,lockwait,status,machine,program from v$session where SID in
(select session_id from V$locked_object)


-If there is a result of the output, it indicates which machine is deadlocked and which one can see the deadlock. Field Description:

--Username: The database user used by the deadlock statement;

--Lockwait: The state of the deadlock if there is a content representation being deadlocked.

-Status: State, active indicates deadlock

Machines: The machine where the deadlock statement resides.

Program: The main application from which to generate the deadlock statement.

--2) You can view the deadlock statement by executing the following statement with the DBA user.

Select Sql_text from V$sql where Hash_value in
(select Sql_hash_value from v$session where SID in
(select session_id from V$locked_object))

Oracle Lock Processing Scripts

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.