Row versioning in MySQL

2019-02-11 07:16发布

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?

Please note that I'm not talking about a TIMESTAMP, which is not reliable as two concurrent updates might happen during the same second.

2条回答
Explosion°爆炸
2楼-- · 2019-02-11 07:27

Yes it is. The more general problem is called slowly changing dimensions.

查看更多
乱世女痞
3楼-- · 2019-02-11 07:40

The only way (I can think of) to do this is a (before-update) trigger that automatically increments the column value.

查看更多
登录 后发表回答