查詢記錄時(shí)給oracle記錄加鎖
oracle記錄加鎖的方法未必人人都會(huì),下面就為您詳細(xì)介紹oracle記錄加鎖的實(shí)現(xiàn)方法,如果您對(duì)此方面感興趣的話,不妨一看。
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列)
--新打開一個(gè)SQL*Plus窗口
conn test/test(test用戶上的第二個(gè)會(huì)話)
delete from a;
此時(shí),系統(tǒng)停頓狀態(tài),等待解鎖,
只要在***個(gè)窗口發(fā)出roll;或commit;命令,即可解除鎖定狀態(tài)。
【編輯推薦】