MariaDB [test]> CREATE TABLE Test1 ( test TIMESTAMP DEFAULT NULL );
|
ERROR 1067 (42000): Invalid default value for 'test'
|
|
MariaDB [test]> CREATE TABLE Test2 ( test TIMESTAMP NULL DEFAULT NULL);
|
Query OK, 0 rows affected (0,054 sec)
|
It works as expected. KB says: "MariaDB also has special behavior if NULL is assigned to column that uses the TIMESTAMP data type. If the column is assigned the NULL value in an INSERT or UPDATE query, then MariaDB will automatically initialize the column's value with the current date and time.
This automatic initialization for NULL values can also be explicitly disabled for a column that uses the TIMESTAMP data type by specifying the NULL attribute for the column. In this case, if the column's value is set to NULL, then the column's value will actually be set to NULL." ( https://mariadb.com/kb/en/timestamp/)
So - first set NULL attribute to timestamp column - then set the default (NULL or something else if needed, CURRENT_TIMESTAMP e.g.)
MariaDB [test]> CREATE TABLE Test1 ( test TIMESTAMP DEFAULT NULL );
ERROR 1067 (42000): Invalid default value for 'test'
MariaDB [test]> CREATE TABLE Test2 ( test TIMESTAMP NULL DEFAULT NULL);
Query OK, 0 rows affected (0,054 sec)
It works as expected. KB says: "MariaDB also has special behavior if NULL is assigned to column that uses the TIMESTAMP data type. If the column is assigned the NULL value in an INSERT or UPDATE query, then MariaDB will automatically initialize the column's value with the current date and time.
This automatic initialization for NULL values can also be explicitly disabled for a column that uses the TIMESTAMP data type by specifying the NULL attribute for the column. In this case, if the column's value is set to NULL, then the column's value will actually be set to NULL." ( https://mariadb.com/kb/en/timestamp/)
So - first set NULL attribute to timestamp column - then set the default (NULL or something else if needed, CURRENT_TIMESTAMP e.g.)