If your sever only have one CPU. you don't need warry about this. beacuse in fact, the CPU just can work one threed at a time.it mean , even you seem it will be execute at the same time , but they can only step by step. other wise , if you have more than one CPU. you can used a flag the possion "on_modify" true/false to do what you want.
或者用写操作锁
/////////////////////////////////
LOCK TABLE t WRITE;执行update以后UNLOCK TABLE t WRITE;
LOCK TABLES
tbl_name [[AS] alias] lock_type
[, tbl_name [[AS] alias] lock_type] ...lock_type:
READ [LOCAL]
| [LOW_PRIORITY] WRITEUNLOCK TABLES请问如何锁住记录?.....没太看明白.....
还有乐观锁可用,就是每行数据增加一个version字段。
具体的去搜索
数据库 乐观锁对于并发访问同一行数据的频率不是太高的比较适合。
参照《数据库管理概论》
如果你和我一样也是新手,就看看那本书的事物处理,你就会明白,什么是封锁协议,怎么用SQL语句那本书说得很清楚。
commit
you don't need warry about this.
beacuse in fact, the CPU just can work one threed at a time.it mean , even you seem it will be execute at the same time , but they can only step by step.
other wise , if you have more than one CPU.
you can used a flag the possion "on_modify" true/false to do what you want.
因为一句 UPDATE SQL 本身就是 atom, 根本不需要特别事务处理建议增加一个编辑 token 用来记录版本或者用户ID
另外可以根据权限或时间转移token