I have the following create table statement.
CREATE TABLE `test_table` (
`id` INT(11) NOT NULL,
`field1` varchar(10),
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);
when I do the following insert, I'll get the erro "Column 'updated_at' cannot be null"
insert into test_table (id, field1, updated_at) values (1234, 'foo', null);
I expected updated_at would just take on the default value in this case.
mysql version 5.7.12
However when I do this in mysql version 5.6, the insert commands works. Is there a change in the versoin from 5.6 to 5.7? The only difference I thought was 5.7 has NO_ZERO_DATE default to true. But I thought that was only for datetime. Is there a configuration change that I need to make?
It's possible to achieve the result by not passing in updated_at but I don't have over insert statement in this case.