真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

怎么解決oracle鎖表,oracle數(shù)據(jù)庫鎖表解決辦法

oracle 表鎖住了什么原因

在對指定表做append操作,其他再做truncate時候,會產(chǎn)生鎖表,如下驗證步驟,

黃巖網(wǎng)站建設公司創(chuàng)新互聯(lián)建站,黃巖網(wǎng)站設計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為黃巖上千余家提供企業(yè)網(wǎng)站建設服務。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設要多少錢,請找那個售后服務好的黃巖做網(wǎng)站的公司定做!

1、創(chuàng)建測試表,

create table test_lock(id number, value varchar2(200));

2、執(zhí)行append語句;并且不做提交,insert /*+append*/ into test_lock values(1,1);

3、再次執(zhí)行清表語句,truncate table test_lock;報鎖表錯誤,

4、查看鎖表語句,發(fā)現(xiàn)被鎖表,

select b.object_name, t.*

from v$locked_object t, user_objects b

where t.object_id = b.object_id

模擬oracle數(shù)據(jù)庫update鎖表現(xiàn)象及處理辦法

Session1創(chuàng)建測試表:

SQL create table test (id number (10) not null , name varchar(20), primary key(id));

Table created.

SQL desc test;

Name Null? Type

----------------------------------------- -------- ----------------------------

ID NOT NULL NUMBER(10)

NAME VARCHAR2(20)

SQL insert into test values(001,'tom');

1 row created.

SQL insert into test values(002,'lisa');

1 row created.

SQL insert into test values(003,'joy');

1 row created.

SQL insert into test values(004,'jia');

1 row created.

查看test表信息

SQL update test set name='xue' where name='joy';

1 row updated.

SQL commit;

Commit complete.

SQL select * from test updata;

ID NAME

---------- --------------------

1 tom

2 lisa

3 xue

4 jia

重新打開session 2:

SQL select * from test;

ID NAME

---------- --------------------

1 tom

2 lisa

3 xue

4 jia

update模擬鎖表

SQL update test set name='da' where name='tom';

1 row updated.

注:不提交

Session2查詢:

SQL select * from test;

ID NAME

---------- --------------------

1 tom

2 lisa

3 xue

4 jia

查看哪個表被鎖

SQL select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;

OWNER

------------------------------

OBJECT_NAME

--------------------------------------------------------------------------------

SESSION_ID LOCKED_MODE

---------- -----------

SYS

TEST

23 3

查看是哪個session引起的

SQL select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;

USERNAME SID SERIAL# LOGON_TIM

------------------------------ ---------- ---------- ---------

SYS 23 23 02-JAN-20

殺掉對應進程

SQL alter system kill session'23,23';

System altered.

其中23為sid,23為serial#.

SQL select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;

no rows selected

SQL select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;

no rows selected

session 1查詢:

SQL select * from test;

select * from test

*

ERROR at line 1:

ORA-00028: your session has been killed

SQL select * from test;

select * from test

*

ERROR at line 1:

ORA-01012: not logged on

Process ID: 5366

Session ID: 23 Serial number: 23

重新連接SQL

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 2 11:39:53 2020

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL select * from test updata;

ID NAME

---------- --------------------

1 tom

2 lisa

3 xue

4 jia

oracle如何解鎖表

一些ORACLE中的進程被殺掉后,狀態(tài)被置為"killed",但是鎖定的資源很長時間不釋放,有時實在沒辦法,只好重啟數(shù)據(jù)庫?,F(xiàn)在提供一種方法解決這種問題,那就是在ORACLE中殺不掉的,在OS一級再殺。

1.下面的語句用來查詢哪些對象被鎖:

select object_name,machine,s.sid,s.serial#

from v$locked_object l,dba_objects o ,v$session s

where l.object_id = o.object_id and l.session_id=s.sid;

2.下面的語句用來殺死一個進程:

alter system kill session '24,111'; (其中24,111分別是上面查詢出的sid,serial#)

【注】以上兩步,可以通過Oracle的管理控制臺來執(zhí)行。

3.如果利用上面的命令殺死一個進程后,進程狀態(tài)被置為"killed",但是鎖定的資源很長時間沒有被釋放,那么可以在os一級再殺死相應的進程(線程),首先執(zhí)行下面的語句獲得進程(線程)號:

select spid, osuser, s.program

from v$session s,v$process p

where s.paddr=p.addr and s.sid=24 (24是上面的sid)

4.在OS上殺死這個進程(線程):

1)在unix上,用root身份執(zhí)行命令:

#kill -9 12345(即第3步查詢出的spid)

2)在windows(unix也適用)用orakill殺死線程,orakill是oracle提供的一個可執(zhí)行命令,語法為:

orakill sid thread

其中:

sid:表示要殺死的進程屬于的實例名

thread:是要殺掉的線程號,即第3步查詢出的spid。

例:c:orakill orcl 12345

oracle 表被鎖住 怎么解鎖

一般先查詢并找到被鎖定的表,解鎖代碼如下:

--釋放SESSION?SQL:?

--alter?system?kill?session?'sid,?serial#';?

ALTER?system?kill?session?'23,?1647';


分享題目:怎么解決oracle鎖表,oracle數(shù)據(jù)庫鎖表解決辦法
網(wǎng)站鏈接:http://weahome.cn/article/hsgcid.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部