skip to Main Content

I can’t find it in the DATETIME but I usually define it as DATETIME with no precision specifier.

I noticed this when Hibernate automatic DDL update is run it alters the table to DATETIME(6)

2

Answers


  1. It indicates the precision to which the milliseconds is stored.
    DATETIME(6) means that the fractional milliseconds is stored upto 6 decimal places. For example, 1970-01-01 17:51:04.789463.
    The number must range between 0 and 6.

    Login or Signup to reply.
  2. This is documented on the page before the actual page you linked to in the ToC (emphasis mine):

    MySQL 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.

    […]

    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.)

    • So DATETIME is equivalent to DATETIME(0).
    • And DATETIME(6) is not equivalent to DATETIME nor DATETIME(0).
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search