Storing microseconds in MySQL: which workaround?

后端 未结 3 1267
無奈伤痛
無奈伤痛 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:50

    If you say that the most popular queries are time base, I would recomend going with a single column that stores the time as in your first option.

    You could pick your own epoch for the application, and work from there.

    This should simplify the queries that needs to be written when searching for the time intervals.

    Also have a look at 10.3.1. The DATETIME, DATE, and TIMESTAMP Types

    However, microseconds cannot be stored into a column of any temporal data type. Any microseconds part is discarded. Conversion of TIME or DATETIME values to numeric form (for example, by adding +0) results in a double value with a microseconds part of .000000

提交回复
热议问题