); 

A TIMESTAMP  column that permits NULL  values does not  take on the current timestamp at insert time except under one of the following conditions: 

•Its default value is defined as CURRENT_TIMESTAMP  and no value is specified for the column 

• CURRENT_TIMESTAMP  or any of its synonyms such as NOW()  is explicitly inserted into the column 

In other words, a TIMESTAMP  column defined to permit NULL  values auto-initializes only if its definition includes DEFAULT CURRENT_TIMESTAMP : 

CREATE TABLE t (ts TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP); 

If the TIMESTAMP  column permits NULL  values but its definition does not include DEFAULT CURRENT_TIMESTAMP , you must explicitly insert a value corresponding to the current date and time. Suppose that tables t1  and t2  have these definitions: 

CREATE TABLE t1 (ts TIMESTAMP NULL DEFAULT ’0000-00-00 00:00:00’); CREATE TABLE t2 (ts TIMESTAMP NULL DEFAULT NULL); 

To set the TIMESTAMP  column in either table to the current timestamp at insert time, explicitly assign it that value. For example: 

INSERT INTO t2 VALUES (CURRENT_TIMESTAMP); INSERT INTO t1 VALUES (NOW()); 

If the explicit_defaults_for_timestamp  system variable is enabled, TIMESTAMP  columns permit NULL  values only if declared with the NULL  attribute. Also, TIMESTAMP  columns do not permit assigning NULL  to assign the current timestamp, whether declared with the NULL  or NOT NULL  attribute. To assign the current timestamp, set the column to CURRENT_TIMESTAMP  or a synonym such as NOW() . 

## 11.2.6 Fractional Seconds in Time Values 

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

•Inserting a TIME , DATE , or TIMESTAMP  value with a fractional seconds part into a column of the same type but having fewer fractional digits results in rounding. Consider a table created and populated as follows: 

CREATE TABLE fractest( c1 TIME(2), c2 DATETIME(2), c3 TIMESTAMP(2) ); INSERT INTO fractest VALUES (’17:51:04.777’, ’2018-09-08 17:51:04.777’, ’2018-09-08 17:51:04.777’); 

The temporal values are inserted into the table with rounding: 

mysql> SELECT * FROM fractest; +-------------+------------------------+------------------------+ | c1 | c2 | c3 | 

