Mysql version is 5.1.73,there can be only one timestamp column with current_timestamp in deafault or on update clause,so I tried to create table:
create table `temp`(
`id` INTEGER NOT NULL auto_increment PRIMARY KEY,
`created_date` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`last_updated_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
And after I executed this sql:
insert into `temp`(id,created_date, last_updated_date) values(1,null, null);
I got this document:
1 2017-02-10 18:17:16 2017-02-10 18:18:13
Here is my question:
- I set
created_dateNOT NULL,why did the insert sql work well?Should it returnError: Column 'xx' cannot be null? - Why did
created_datecolumn get a value and it is not the default value?
Thanks.