我需要在表中插入以下格式的日期:
11:40:18.111
我的MySQL版本是5.0.9,我一直用的是Time 邮票,但我从来不需要使用毫秒。如何在这个版本的mysql中以这种格式(HH:MM:SS.sss)将这些数据写入数据库?
抱歉我的英语不好:P
最佳答案
根据MySQL 5.5 reference manual ,
A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. Although this fractional part is recognized, it is discarded from values stored into DATETIME or TIMESTAMP columns.
MySQL 5.0 文档(应该说同样的事情)可用 here .
看起来 Version 5.7 中添加了对小数秒的支持。因此,如果您想要毫秒级的 native 支持,则需要升级。
如果您坚持使用 5.0,您可以使用另一个字段,仅显示几毫秒。当然,这会有点棘手......
关于mysql - 在MYSQL中插入日期、小时、分钟、秒和毫秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51388590/