MySQL 解锁 Oracle 表

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

Unlock An Oracle Table

mysqloraclesessionlocking

提问by Ali786

What are the different techniques for Unlocking an oracle table?

解锁 oracle 表有哪些不同的技术?

What I Tried.

我试过的。

  1. Get the object ID of the locked table:

    SELECT object_id FROM dba_objects WHERE object_name='YOUR TABLE NAME';

  2. Get the SID values for this ID:

    SELECT sid FROM v$lock WHERE id1=OBJECT ID FROM STEP1

  3. Get the session values for these SIDs:

    SELECT sid, serial# from v$session where sid in (COMMA SEPARATED LIST OF SIDs FROM STEP2.)

  4. Kill the sessions causing the lock:

    ALTER SYSTEM KILL SESSION (SID,SERIAL#)

  1. 获取锁定表的对象ID:

    SELECT object_id FROM dba_objects WHERE object_name='YOUR TABLE NAME';

  2. 获取此 ID 的 SID 值:

    SELECT sid FROM v$lock WHERE id1=OBJECT ID FROM STEP1

  3. 获取这些 SID 的会话值:

    SELECT sid, serial# from v$session where sid in (COMMA SPARATED LIST OF SIDs FROM STEP2.)

  4. 杀死导致锁定的会话:

    更改系统终止会话(SID,序列号)

pair values from step 3 e.g. ALTER SYSTEM KILL SESSION '231,23454'

对来自第 3 步的值,例如 ALTER SYSTEM KILL SESSION '231,23454'

But The Problem is I have lot of tables which has been locked is there any other technique for unlocking the tables.

但问题是我有很多表已被锁定,是否还有其他解锁表的技术。

I am using SQLDeveloper Is there any direct option for unlocking it.

我正在使用 SQLDeveloper 是否有任何直接的选项可以解锁它。

回答by Vinoth Kumar

Option 1:

选项1:

Well, one of the options is to rollback the locked SQL statement. For an instance,

那么,选项之一是回滚锁定的 SQL 语句。例如,

lock table table1 in exclusive mode;  -- is what you should've used to lock the table.

To unlock: rollback;

解锁:回滚;

Option 2:

选项 2:

To find username and sid:

要查找用户名和 sid:

select * from v$locked_object;

To find serial# using sid:

使用 sid 查找 serial#:

select * from v$session where sid= put the sid you found on v$locked_object;

To kill session:

杀死会话:

alter system kill session 'sid, serial#'; -- Execute this command as sysdba as normal user won't have privilege.