【點(diǎn)擊:】
阿木伯 著
|
|
怎樣在查詢記錄時(shí)給記錄加鎖? |
|
- 系統(tǒng)環(huán)境:
1、操作系統(tǒng):Windows 2000
2、數(shù)據(jù)庫(kù): Oracle 8i R2 (8.1.6) for NT 企業(yè)版
3、安裝路徑:C:\ORACLE
- 實(shí)現(xiàn)方法:
利用SELECT的FOR UPDATE子句實(shí)現(xiàn)
conn system/manager
--創(chuàng)建實(shí)驗(yàn)用戶
grant connect,resource to test identified by test;
conn test/test
--創(chuàng)建實(shí)驗(yàn)表1
create table a(a number);
insert into a values(1);
commit;
select * from a for update;
或
select * from a for update of a.a;(a表的a列)
--新打開(kāi)一個(gè)SQL*Plus窗口
conn test/test(test用戶上的第二個(gè)會(huì)話)
delete from a;
此時(shí),系統(tǒng)停頓狀態(tài),等待解鎖,
只要在第一個(gè)窗口發(fā)出roll;或commit;命令,即可解除鎖定狀態(tài)。
|
【最后更新:】 |
|