开发者

MySQL checking value is not default value

is开发者_开发问答 there a 'handy' way to check whether a column value has been changed in mySQL? I presume it will need to check against the default value of the column.

thanks.


You could use MySQL TIMESTAMP and ON UPDATE to update a timstamp column when a row is updated.

The DDL would go something like this:

last_update TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP

Now you can know if a row was changed by looking at last_update - and as a bonus, you can now also know when it was changed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜