Solution to update and delete Oracle records locked by another user

Source: Internet
Author: User

1. view the database lock and diagnose the source and type of the lock:
Select object_id, session_id, locked_mode from v $ locked_object;
Or run the following command:
Select B. owner, B. object_name, l. session_id, l. locked_mode
From v $ locked_object l, dba_objects B
Where B. object_id = l. object_id

SELECT lpad ('', decode (l. xidusn, 0,3, 0) | l. Oracle_username User_name,
O. owner, o. object_name, o. object_type, s. sid, s. serial #
FROM v $ locked_object l, dba_objects o, v $ session s
WHERE l. object_id = o. object_id
AND l. session_id = s. sid
Order by o. object_id, xidusn DESC

2. Find the database's serial # For killing:
Select t2.username, t2.sid, t2.serial #, t2.logon _ time
From v $ locked_object t1, v $ session t2
Where t1.session _ id = t2.sid order by t2.logon _ time;

3. Kill the session
Alter system kill session 'sid, serial #'
Use the record found in step 2 to delete the statement.

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.