Oracle Lock table and wait

Source: Internet
Author: User

/*oracle user Lock, database lock sometimes compared to eat resources, if a large number of resources consumed, then other applications will not have the resources to use, it will be abnormally closed or unable to open. When Oracle has a lock waiting, it must find the waiting lock, if necessary, find the corresponding session and kill it. */

"Kill the Conversation."

> alter system kill session ' sid,serial '--This is the time to find Sid and Serial> select Sid,serial from V$session in V$session

SELECT/*+ Rule */S.username,decode (l.type, ' TM ', ' TABLE lock ',              ' TX ', ' ROW lock ',              NULL) Lock_level,o.owner, O.object_name,o.object_type,s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuserfrom v$session S,v$lock L,dba_ Objects Owhere L.sid = S.sidand L.id1 = o.object_id (+) and s.username are not NULL---ERP----------------------------------E Rpselect Lower (SUBSTR (all_objects.owner| | object_name,1,16)),                       SUBSTR (os_user_name,1,10),                       v$locked_object.process,                       SUBSTR (terminal,1,7),                       v$session.sid,v$session.serial#,                       v$session.machine from                    v$locked_object,all_objects,v$session                   WHERE v$locked_object.object_id=all_objects.object_id and                     V$locked_object. Session_id=v$session. SID----ERP----------------------------------ERP

/* If there is a lock waiting, you need to find out who caused the wait */

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#from v$locked_object L,dba_ Objects o,v$session swhere l.object_id=o.object_idand l.session_id=s.sidorder by o.object_id,xidusn desc Above query result is a tree-like structure If there is a child node, it indicates that there is a wait to occur. If you want to know which rollback segment the lock uses, you can also associate to V$rollname, where Xidusn is the USN of the rollback segment

Oracle Lock table and wait

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.