标签:space 字段 时间 def names int pre timestamp null
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;
######上面的建表语句不会成功执行,需要修改成下面这样的,原因是因为timestamp类型的字段与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;
标签:space 字段 时间 def names int pre timestamp null
原文地址:https://www.cnblogs.com/igoodful/p/11684226.html