use database_name; -- -- namespace table -- CREATE TABLE `table_name` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL COMMENT '名字', `create_time` timestamp NOT NULL COMMENT '创建时间', `update_time` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), UNIQUE KEY `uk_name` (`name`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='table_name' AUTO_INCREMENT = 1;
###### construction of the table above statement does not execute successfully, you need to modify the following into this, the reason is because the timestamp type field with CURRENT_TIMESTAMP
use database_name; -- -- namespace table -- CREATE TABLE `table_name` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL COMMENT '名字', `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), UNIQUE KEY `uk_name` (`name`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='table_name' AUTO_INCREMENT = 1;