update A set A.id=1 where A.name='zw' ----1
update A set A.id=2 where A.name='zw' ----2
我想实现在修改语句一的时候,语句二不能执行.请各位大哥给点建议吧.谢谢了.说详细一点.小弟万分感激.
[b]问题补充:[/b]
sybase数据库
create table abc(
cat_id int not null,
section_id varchar(10) not null,
attr_id varchar(10) not null,
key_attr_seq int not null,
constraint a primary key(cat_id,section_id,attr_id)
)
alter table abc add rid int identity
alter table abc lock [datarows] --加入行级锁
计算机A: begin tran
select * from abc
waitfor delay '00:00:20'
commit tran
计算机B:update abc set section_id='999' where rid=5
请问为何在A运行时机B仍然能修改表abc的数据呢
我想实现在A运行上面SQL时其它进程只能查看,不能更新A查询出来的数据.
谢谢.
[b]问题补充:[/b]
数据库表abc已经写死了,不能随意的添加字段.
[b]问题补充:[/b]
好象不行哦.constraint a primary key(cat_id,section_id,attr_id) 是复合主键盘,不行的.更新的是key_attr_seq 字段.
[b]问题补充:[/b]
key_attr_seq 字段是在UI上用户更新的字段.所以不能把它作为一个标识字段随意增加.能否给我提供怎么加锁呀.加哪种锁比较好.谢谢.
[b]问题补充:[/b]
恩,我试试.除了这种方法还有其它的办法吗.比如数据库的隔离级别或者加锁之类的.
[b]问题补充:[/b]
恩,十分感谢.