The default setting method for datetime type in mysql, mysqldatetime
An error occurred while modifying the default datetime value through the navicat client.
The field type of the database table is datetime. The default value is NULL. When the default value is set to the current time on the interface, the message "1067-Invalid default value for 'create _ TM '" is displayed '", this problem does not occur during table creation, for example, the table creation statement:
Create table 'app _ info1' ('id' bigint (21) unsigned not null AUTO_INCREMENT COMMENT 'Primary key id', 'app _ id' varchar (30) default null comment 'app Code', 'app _ name' varchar (30) default null comment 'app name', 'package _ name' varchar (100) default null comment 'package name', 'version' int (11) default null comment' version', 'version _ name' varchar (20) default null comment' version name ', 'icon _ url' varchar (512) default null comment 'icon address', 'Download _ url' varchar (512) default null comment', 'summary 'varchar (512) default null comment 'summary', 'desc' varchar (512) default null comment' description information', 'app _ status' int (4) DEFAULT '0' comment' status 0: available, 1: Delete ', 'create _ time' datetime DEFAULT CURRENT_TIMESTAMP COMMENT' creation time', 'create _ user' varchar (30) default null comment 'creator ', 'modify _ time' datetime DEFAULT CURRENT_TIMESTAMP comment' modify time', 'modify _ user' varchar (30) default null comment' modifier ', primary key ('id ')) ENGINE = InnoDB AUTO_INCREMENT = 2 default charset = utf8;
Then I tried to directly modify the field through the script, which is also OK, as shown below:
Alter table ts_role MODIFY column create_tm datetime default CURRENT_TIMESTAMP COMMENT 'creation time'
Of course, I have installed Mysql 5.6 or above, but I have not tried any other versions.
The default value setting method for datetime type in mysql is all the content shared by the editor. I hope you can give us a reference and support the help house.