admin管理员组文章数量:1612098
mysql中,类型为timestamp的列,默认为current_timestamp类型,并且在更新的时候会自动更新为当前值。因此一个表中设置多个timestamp类是没有意义的,一般设置为datatime类型。
TIMESTAMP列创建后的格式是:
a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
一般,创建表的时候,创建时间字段用datatime,更新时间字段用timestamp
timestamp与datatime区别
(1)显示
格式相同,都是19个字符长:YYYY-MM-DD HH:MM:SS
(2)范围
datetime :支持的范围为”1000-01-01 00:00:00”到”9999-12-31 23:59:59”
TIMESTAMP:值不能早于1970或晚于2037
(3)存储
TIMESTAMP
1.4个字节储存(Time stamp value is stored in 4 bytes)
2.值以UTC格式保存( it stores the number of milliseconds)
3.时区转化 ,存储时对当前的时区进行转换,检索时再转换回当前的时区。
datetime
1.8个字节储存(8 bytes storage)
2.实际格式储存(Just stores what you have stored and retrieves the same thing which you have stored.)
3.与时区无关(It has nothing to deal with the TIMEZONE and Conversion.)
版权声明:本文标题:mysql中timestamp类型的列默认值为current_timestamp的只能有一个 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728629608a1166938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论