Oracle View lock table condition and handle lock table

Source: Internet
Author: User

/**locked*query locked object and analyse Reason,kill it**/select ' alter system kill session ' | | SID | | ',' || serial# | |  ''';' From (select distinct A.sid, a.serial#, status, Machi         NE, lockwait, logon_time from V$session A, V$locked_object b WHERE (a.status = ' ACTIVE ' or a.status = ' INACTIVE ') and A.sid = b.session_id and B.oracle_username = ' xyhistest '--plus user name can filter user resources)/*2, batch execute the first step generated statement alter system kill session ' sid,serial# '; alter system kill Sess Ion ' 6976,33967 '; *//*3, query Oracle user name, machine name, Lock Table object */select l.session_id sid, S.serial#, L.locked_mode, L.ora Cle_username, L.os_user_name, S.machine, S.terminal, O.object_name, s.logon_time from V$loc Ked_object L, all_objects o, v$session s WHERE l.object_id = o.object_id and l.session_id = S.sid ORDER by SID, S.serial #;/*3 or */sele.CT S.sid, S.osuser, p.spid as Ospid, S.machine, S.terminal, S.program from V$session S, v$process p where S.sid = 6--ses sion_id and s.paddr = p.addr;/*4, query is what SQL statement causes the lock table */select B.sql_text from V$session A, v$sql b where a.sid = 6--sessio n_id and a.sql_address = b.address (+),/*5, query is a */select l.session_id sid that causes the lock table to be executed by the SQL statement, s.serial#, L.locked_mod       E, L.oracle_username, s.user#, L.os_user_name, S.machine, s.terminal, A.sql_text, A.action from V$sqlarea A, v$session s, v$locked_object l WHERE l.session_id = s.sid and s.prev_sql_addr = a.address ORDER by Sid, S.serial#;


Oracle View lock table condition and handle lock table

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.