开发者

MySQL checking value is not default value

开发者 https://www.devze.com 2023-03-12 06:26 出处:网络
is开发者_开发问答 there a \'handy\' way to check whether a column value has been changed in mySQL?

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

精彩评论

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