How to kill deadlocks in oracle

Source: Internet
Author: User

Run the following statement to view the deadlock:

Select/* + rule */lpad ('', decode (l. xidusn, 0, 3, 0) | l. oracle_username User_name, o. owner, o. object_name, o. object_type, s. sid, s. serial #, p. spidfrom v $ locked_object l, dba_objects o, v $ session s, v $ process p where l. object_id = o. object_idand l. session_id = s. sidand s. paddr = p. addr order by o. object_id, xidusn DESC;

 

(The purpose of executing this statement is to find the SID and SERIAL # Of the deadlock you need to kill. Note: we do not recommend that you kill others' deadlocks, it is possible that someone else is locking the table while you are querying the deadlock, and you are querying the deadlock. In fact, when you query the deadlock again, someone else's lock has been resolved. Therefore, it is not recommended to kill the lock of your own table .) Now, find the table name you want to operate on, find the corresponding SID and SERIAL # to replace the variables in the following statement, and then execute the command to unlock the table.
Alter system kill session 'sid, serial #';

 

If the SID and SERIAL # are respectively: 35, then you should execute the statement to kill the deadlock as follows:
Alter system kill session '2017 0 ';

 

Then execute the first statement to see if your deadlock has been killed? It will certainly succeed!

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.