ITPub博客

首页 > 数据库 > Oracle > 在oracle查询记录时给记录加锁(转)

在oracle查询记录时给记录加锁(转)

原创 Oracle 作者:post0 时间:2007-08-10 21:20:56 0 删除 编辑
在oracle查询记录时给记录加锁(转)[@more@]

实现方法:

利用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;命令,即可解除锁定状态。

LinuxAid Win

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8225414/viewspace-942783/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    2018
  • 访问量
    8225863