How to insert a microsecond-precision datetime into mysql?

后端 未结 4 2118
野的像风
野的像风 2020-12-28 15:38

I have a string like this:

2011-11-11 11:11:11.111111

and I need to insert it in MySql, into a datetime column. But after I insert it, it b

4条回答
  •  盖世英雄少女心
    2020-12-28 16:11

    As documented under Fractional Seconds in Time Values:

    A trailing fractional seconds part is permissible for temporal values in contexts such as literal values, and in the arguments to or return values from some temporal functions. Example:

    mysql> SELECT MICROSECOND('2010-12-10 14:12:09.019473');
    +-------------------------------------------+
    | MICROSECOND('2010-12-10 14:12:09.019473') |
    +-------------------------------------------+
    |                                     19473 |
    +-------------------------------------------+
    

    However, when MySQL stores a value into a column of any temporal data type, it discards any fractional part and does not store it.

    Note that this behaviour has changed in v5.6.4.

提交回复
热议问题