Can MySQL set a validity period for the value of a certain field?
仅有的幸福
仅有的幸福 2017-05-18 10:54:45
0
4
1356

I want to set a validity period of 10 minutes for the value of a certain field. After 10 minutes, it becomes Null. Does mysql have this function?

仅有的幸福
仅有的幸福

reply all(4)
滿天的星座

Just give a valid time field directly, and the code layer will make a logical judgment and give a null value after the validity period.

PHPzhong

You can write a trigger and change its status after the effective time

给我你的怀抱

Add two fields directly. In fact, you don’t need to change that field to null. You only need to judge the time at the logical level when using it. Mysql itself does not have this function

世界只因有你

It is recommended to use the logic code layer to handle it. After all, the database is only a function of accessing data, and these functions should not be mixed. By adding an additional creation time field, the code can determine whether it has expired.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template