Storing microseconds in MySQL: which workaround?

后端 未结 3 1203
無奈伤痛
無奈伤痛 2021-02-20 13:48

we\'re writing a scientific tool with MySQL support. The problem is, we need microsecond precision for our datetime fields, which MySQL doesn\'t currently support. I see at leas

3条回答
  •  温柔的废话
    2021-02-20 14:51

    MySQL will support microseconds, see MySQL 5.6.4 changelog:

    Fractional Seconds Handling

    Incompatible Change: MySQL now permits fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) precision. To define a column that includes a fractional seconds part, use the syntax type_name(fsp), where type_name is TIME, DATETIME, or TIMESTAMP, and fsp is the fractional seconds precision. For example:

    CREATE TABLE t1 (t TIME(3), dt DATETIME(6)); The fsp value, if given, must be in the range 0 to 6. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. (This differs from the standard SQL default of 6, for compatibility with previous MySQL versions.)

    The following items summarize the implications of this change. See also Section 10.3.5, “Fractional Seconds in Time Values”.

提交回复
热议问题