I created a few MySQL tables via phpMyAdmin. Then I noticed that in table definitions some TIMESTAMP
columns have a value attached:
timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)
What does it mean and what value should I use?
I created a few MySQL tables via phpMyAdmin. Then I noticed that in table definitions some TIMESTAMP
columns have a value attached:
timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)
What does it mean and what value should I use?
2
Answers
This syntax is for fractional second precision, see the reference manual:
https://dev.mysql.com/doc/refman/8.0/en/fractional-seconds.html
MySQL 8.0 has fractional seconds support for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) precision
The value after the type defines the fractional seconds part. To quote the documentation:
Therefore, to define a timestamp column with sub-second precision, you must specify a nonzero value.