plsql表鎖被占用 解決Oracle鎖表

2021-10-13 05:07:27 字數 2939 閱讀 7983

概述:

鎖表是很容易發生的現象,當有多人對錶進行操作時就容易發生。如下是解決鎖表的步驟

鎖表原因:

由於oracle資料庫具有保持資料的一致性,所以當乙個人對錶進行操作,沒有提交,另乙個人在需要操作的時候,就不能操作,必須等表提交,就一直處於等待狀態,就導致鎖表。

鎖表報錯資訊:

如果發現修改乙個表資料時不能提交而報下面的錯誤:

record is locked by another user

解決方法:

殺死會話程序或者再執行sql語句,然後提交。

解決步驟:

1. 登陸資料庫,以sys使用者登陸

sql> conn /as sysdba

connected.

sql>

sql>

sql>

2. 查詢哪些會話被鎖。

sql> select t2.username, t2.sid, t2.serial, t2.logon_time from v$locked_object t1,v$session t2 where t1.session_id=t2.sid order by t2.logon_time;

username                              sid    serial logon_time

ipms                                  494      10320 2014-01-23 08:03:38

ipms                                  479      25009 2014-01-23 08:04:50

hcba                                  401      59957 2014-01-23 08:43:23

sql>

sql>

sql>

2.1. 檢視會話具體內容

sql> select sql_text from v$session a,v$sqltext_with_newlines b where decode(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value and a.sid=&sid order by piece;

enter value for sid: 494  ------     (在此輸入sid號)

old   1: select sql_text from v$session a,v$sqltext_with_newlines b where decode(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value and a.sid=&sid order by piece

new   1: select sql_text from v$session a,v$sqltext_with_newlines b where decode(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value and a.sid=494 order by piece

sql_text

update ipms.is_standard d  set d.is_lockcount = d.is_lockcount -

where m.im_gbid in

(select

sql_text

g.igb_id

from ipms.is_grantb

ill g  inner join ipms.wwf_instance i on g.igb_flowid =  i.insta

nce_id

where i.instance_id=:i

nstance_id)

and d.im_id = m.im_id

and d.is_lock = 1

sql_text

10 rows selected.

2.2 查詢會話具體內容

sql> select sql_text from v$session a,v$sqltext_with_newlines b where decode(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value and a.sid=&sid order by piece;

enter value for sid: 479(在此輸入sid號)

old   1: select sql_text from v$session a,v$sqltext_with_newlines b where decode(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value and a.sid=&sid order by piece

new   1: select sql_text from v$session a,v$sqltext_with_newlines b where decode(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value and a.sid=479 order by piece

sql_text

begin

sys.dbms_output.get_line(line => :line, status => :statu

s);end;

3. 殺死該會話

根據剛才查詢出來的sid號和serial值。

sql>

sql> alter system kill session '494,10320';

system altered.

sql> alter system kill session '479,25009';

system altered.

sql> commit;

commit complete.

sql>

Ubuntu鎖被占用

解決方法 1.ps aux grep apt 檢視下面有哪幾個程序 例如 mr18 2739 0.0 0.0 21536 1044 pts 0 s 21 32 0 00 grep color auto apt 2.sudo kill 2739 這樣子就完成了 如果有多個就全部kill 報錯無法獲得鎖...

解決Tensorboard埠被占用

報錯資訊 e1220 06 55 50.868322 mainthread program.py 267 tensorboard attempted to bind to port 6006,but it was already in use e1220 06 55 50.868322 139684...

解決80埠被占用

什麼?玩了iis又要玩apache麼 80埠被占用?不用擔心,此處有招式 按 win r鍵調出執行視窗 建議用管理員身份執行 輸入cmd回車,彈出命令列視窗 輸入net stop http 回車 此時會停止一些服務。不過某些未知情況下還是不能解決 所以需要從起 但是從起的時候 這些服務就又執行起來了...