Data | database
When we operate the database, sometimes due to improper operation caused the database table is locked, so we often overwhelmed, do not know how to unlock these tables, in the Pl/sql Developer Tool menu "Tools" inside the "sessions" can be queried now existing sessions, But it's hard to find that the session is locked, so it's even harder to find the locked session, which is called a query to query the locked session. As follows:
select Sn.username, M.sid,sn. serial#, m.type, DECODE (m.lmode, 0, ' None ', 1, ' Null ', 2, ' Row Share ', 3, ' Row excl. ', 4, ' Share ', 5, ' s/row excl. ', 6, ' Exclusive ', Lmode, LTRIM (To_char (Lmode, ' 990 ')) ) lmode, DECODE (m.request, 0, ' None ', 1, ' Null ', 2, ' Row Share ', 3, ' Row excl. ', 4, ' Share ', 5, ' s/row excl. ', 6, ' Exclusive ', request, LTRIM (To_char (m.request, ' 990 ')) ) request, m.id1, m.id2 from V$session sn, v$lock m WHERE (SN. SID = m.sid and m.request!= 0) -there is a lock request that is blocked & nbsp OR ( sn. SID = m.sid -There are no lock requests, but locked objects are locked by other session requests and m.request = 0 and Lmode!= 4 & nbsp; and (ID1, Id2) in ( SELECT S.id1, s.id2 from V$lock s WHERE Request!= 0 and s.id1 = m.id1 and S.id2 = M.id2) order by ID1, Id2, m.request;
Through the above query know Sid and Serial# can kill the alter system kill session ' sid,serial# ';
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.