Oracle 数据库在 UPDATE 查询中无限挂起

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7501776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:19:27  来源:igfitidea点击:

Oracle database is hanging infinitly in UPDATE queries

sqloracletransactionsoracle11g

提问by erni313

suddenly my update queries are not executing . i can make selectqueries but when i try to updaterecords the database hangs infinitly. i tried even from sql plus and nothing happens.

突然我的更新查询没有执行。我可以进行 选择查询,但是当我尝试更新记录时,数据库会无限挂起。我什至从 sql plus 尝试过,但没有任何反应。

回答by Adriano Carneiro

Most likely you have another open uncommitted transaction for the same set of records, so they are locked for that transaction.

最有可能的是,对于同一组记录,您有另一个未提交的未提交事务,因此它们已被锁定以用于该事务。

And, most likely, youlocked them, running the same UPDATEin another transaction.

而且,最有可能的是,锁定了它们,UPDATE在另一个事务中运行相同的操作。

Just Commit/rollback your transactions, you should be fine.

只需提交/回滚您的交易,您应该没问题。

回答by DCookie

This query will show you who is blocking your update. Execute the update that hangs, then in another session run this:

此查询将显示谁阻止了您的更新。执行挂起的更新,然后在另一个会话中运行:

select s1.username || '@' || s1.machine ||
  ' ( SID=' || s1.sid || ' )  is blocking '
  || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
  from v$lock l1 join v$lock l2 on (l1.id1 = l2.id1 and l2.id2 = l2.id2) 
                 JOIN v$session s1 ON (s1.sid = l1.sid)
                 JOIN v$session s2 ON (s2.sid = l2.sid)
  WHERE l1.BLOCK=1 and l2.request > 0;

EDIT:

编辑:

To properly attribute this, it looks like I cribbed this a while back from ORAFAQ.

为了正确地归因于这一点,看起来我不久前ORAFAQ 抄袭了它