mysql的TIMESTAMP多支持6位小数(微秒)
ADATETIME
orTIMESTAMP
value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. In particular, any fractional part in a value inserted into aDATETIME
orTIMESTAMP
column is stored rather than discarded. With the fractional part included, the format for these values is'YYYY-MM-DD hh:mm:ss[.fraction]'
, the range forDATETIME
values is'1000-01-01 00:00:00.000000'
to'9999-12-31 23:59:59.999999'
, and the range forTIMESTAMP
values is'1970-01-01 00:00:01.000000'
to'2038-01-19 03:14:07.999999'
. The fractional part should always be separated from the rest of the time by a decimal point; no other fractional seconds delimiter is recognized.
MySQL has fractional seconds support 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)
, wheretype_name
isTIME
,DATETIME
, orTIMESTAMP
, andfsp
is the fractional seconds precision. For example:
CREATE TABLE t1 (t TIME(3), dt DATETIME(6));
Thefsp
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.)
相关文章