SQL 在 Oracle 10 中删除锁

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13845655/
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-01 12:36:03  来源:igfitidea点击:

Removing Locks in Oracle 10

sqloraclesqlplus

提问by Thomas Pollock

I have an issue when trying to update a column value in sqlplus.

尝试更新 sqlplus 中的列值时遇到问题。

It basically wont complete and just hangs. I am wondering if there is anyway to remove locks in oracle by force?

它基本上不会完成,只是挂起。我想知道是否有办法强制删除oracle中的锁?

I've noticed a table called v$locked_object which does contain an onject ID relevant to the issue I am having.

我注意到一个名为 v$locked_object 的表,它包含一个与我遇到的问题相关的 onject ID。

Hope I've explained this good enough.

希望我已经解释得足够好。

Thanks in advance for any help!

在此先感谢您的帮助!

回答by Mari

This will exactly serve your purpose:

这将完全符合您的目的:

SELECT SESSION_ID FROM DBA_DML_LOCKS WHERE NAME = <TABLE_NAME>;

Use the SESSION_IDto find the corresponding SERIAL#with this statement:

使用SESSION_ID找到SERIAL#与此语句对应的语句:

SELECT SID, SERIAL# FROM V$SESSION WHERE SID IN (
    SELECT SESSION_ID FROM DBA_DML_LOCKS WHERE NAME = <TABLE_NAME>
);

Locate the offending tuples SID, SERIAL#and release it like this:

找到有问题的元组SID, SERIAL#并像这样释放它:

ALTER SYSTEM KILL SESSION 'SID, SERIAL#';

回答by Thomas Pollock

Managed to resolve this issue.

设法解决了这个问题。

I looked in DBA_BLOCKERS table and got the session ID. Then killed the session and the lock was removed.

我查看了 DBA_BLOCKERS 表并获得了会话 ID。然后终止会话并删除锁。

回答by Codo

Probably, somebody else has updated the same table and hasn't committed yet. It might even be you (in a different tool or a different session).

可能其他人已经更新了同一张表,但尚未提交。甚至可能是您(在不同的工具或不同的会话中)。

The easiest way to get rid of the lock is to commit the work in the other session.

摆脱锁定的最简单方法是在另一个会话中提交工作。