那么其他要更新该表的用户将怎样等待,有类似sql server 中的WAITFOR DELAY 吗?
wait n n是时间 nowait 不等待
本人找到一篇文章,摘录如下: 利用SELECT的FOR UPDATE子句实现conn system/manager--创建实验用户 grant connect,resource to test identified by test;conn test/test--创建实验表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列)--新打开一个SQL*Plus窗口 conn test/test(test用户上的第二个会话) delete from a;此时,系统停顿状态,等待解锁, 只要在第一个窗口发出roll;或commit;命令,即可解除锁定状态。注:本人测试通过
锁表之后别人是不能更新这个表了,如果有人这个时候要更新这个表的话会等待,可以加no wait不等待,直接返回异常。
锁等待是很麻烦的。所以要及时提交或回滚
吗?
nowait 不等待
利用SELECT的FOR UPDATE子句实现conn system/manager--创建实验用户
grant connect,resource to test identified by test;conn test/test--创建实验表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列)--新打开一个SQL*Plus窗口
conn test/test(test用户上的第二个会话)
delete from a;此时,系统停顿状态,等待解锁,
只要在第一个窗口发出roll;或commit;命令,即可解除锁定状态。注:本人测试通过