MySQL中的行版本控制 [英] Row versioning in MySQL
本文介绍了MySQL中的行版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在表中包含一个整数版本字段,对行的每次更新都会自动递增.在MySQL中可以做到这一点吗?
I would like to include an integer version field in my table, auto-incrementing on each update made to a row. Is it possible to do this in MySQL?
请注意,我并不是在说TIMESTAMP
,因为它可能会在同一秒内发生两次并发更新,所以它不是很可靠.
Please note that I'm not talking about a TIMESTAMP
, which is not reliable as two concurrent updates might happen during the same second.
推荐答案
(我能想到的)唯一的方法是(自动更新)触发器,该触发器会自动增加列值.
The only way (I can think of) to do this is a (before-update) trigger that automatically increments the column value.
这篇关于MySQL中的行版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文