【Oracle】查询锁表的用户并处理

–锁表查询




1. <span class="pln">SQLSELECT object_name</span><span class="pun">,</span><span class="pln"> machine</span><span class="pun">,</span><span class="pln"> s</span><span class="pun">.</span><span class="pln">sid</span><span class="pun">,</span><span class="pln"> s</span><span class="pun">.</span><span class="pln">serial</span><span class="com"># </span>
2. <span class="pln">FROM gv$locked_object l</span><span class="pun">,</span><span class="pln"> dba_objects o</span><span class="pun">,</span><span class="pln"> gv$session s </span>
3. <span class="pln">WHERE l</span><span class="pun">.</span><span class="pln">object_id</span><span class="pun"> =</span><span class="pln"> o</span><span class="pun">.</span><span class="pln">object_id </span>
4. <span class="pln">AND l</span><span class="pun">.</span><span class="pln">session_id </span><span class="pun">=</span><span class="pln"> s</span><span class="pun">.</span><span class="pln">sid</span><span class="pun">;</span>




找到被锁定的表,解锁


–释放SESSION SQL:




1. <span class="pun">--</span><span class="pln">alter system kill session </span><span class="str">'sid, serial#'</span><span class="pun">;</span>
2. <span class="pln">ALTER system kill session </span><span class="str">'23, 1647'</span><span class="pun">;</span>


your support will encourage me to continue to create!
版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)