56,675
社区成员
发帖
与我相关
我的任务
分享
start transaction
select * into 当前值 where id=xxx for update
if 旧值<>当前值 then
-- 此记录在你修改的时候,它人已经修改
rollback
end if
update .... set xxx=新值 where id=xxx
commit
需要比较的字段看你业务需求,一般是重要字段,有的数据库有版本号概念(如postgresql),可以用版本号来比较。