MySQL时间戳列 [英] mysql timestamp column

查看:85
本文介绍了MySQL时间戳列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在MySQL表中定义一个timestamp列,该列将在每次修改同一行中的字段时自动更新?理想情况下,此列最初应设置为插入行的时间.

Is it possible to define a timestamp column in a MySQL table that will automatically be updated every time a field in the same row is modified? Ideally this column should initially be set to the time a row was inserted.

干杯, 唐

推荐答案

这是

That is the default functionality of the timestamp column type. However, note that the format of this type is yyyymmddhhmmss (all digits, no colons or other separation).

编辑:以上有关格式的注释仅适用于MySQL< 4.1 ...更高版本将其格式化为 DateTime

The above comment about the format is only true for versions of MySQL < 4.1... Later versions format it like a DateTime

这篇关于MySQL时间戳列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆