If I create a table
CREATE TABLE t1 (
id BIGINT UNSIGNED NOT NULL,
createDate TIMESTAMP(3) NOT NULL,
updateDate TIMESTAMP(3) NULL DEFAULT NULL,
closeDate TIMESTAMP(3) NULL DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
createDate
column is created as
`createDate` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
1) What is the logic behind this? Why MySQL adds the default value? And why it adds ON UPDATE CURRENT_TIMESTAMP(3)
?
2) Is it possible to create a column timestamp(3) NOT NULL
without the default value?
EDIT1:
I have an impression that id
column, for example, does not have a default value, because if I do
insert t1 updateDate values (now());
I get
ERROR 1364 (HY000): Field 'id' doesn't have a default value
so the default value is not added automatically to a column of INT type.