MySQL里timestamp的默认值设置
timestamp 有以下几种默认值设置:
1.timestamp :表示该字段在插入和更新时都不会自动设置为当前时间。
2.timestamp default current_timestamp :字段插入时如果没有时间则自动设置为当前时间,更新没有变化。
3.timestamp on update current_timestamp:字段插入不会自动设置,字段更新时没有指定时间则自动设置为当前时间。
4.default current_timestamp on update current_timestamp:插入和修改字段时如果没有指定时间则会自动设置为当前时间。
5.timestamp default ‘yyyy–mm–dd hh:mm:ss’ on update current_timestamp :
插入时如果没有则给一个定值,刷新时没有时间则设置为当前时间。
本文详细介绍了MySQL中timestamp字段的五种默认值设置方式,包括插入和更新时的行为,帮助理解并正确使用timestamp类型。

1208

被折叠的 条评论
为什么被折叠?



