问题描述:在利用MySQL语句建立表结构时出现了Error Code : 1293
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause错误
其建表语句为:
CREATE TABLE mooc_user_t(
UUID INT PRIMARY KEY AUTO_INCREMENT COMMENT '主键编号',
user_name VARCHAR(50) COMMENT '账号',
user_pwd VARCHAR(50) COMMENT '密码',
begin_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间'
) COMMENT '用户表' ENGINE = INNODB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
错误原因:在创建表结构时有且只有一个可以在default或者update时带上CURRENT_TIMESTAMP
解决办法:只让一个TIMESTAMP列在设置默认值或更新时带上CURRENT_TIMESTAMP
CREATE TABLE mooc_user_t(
UUID INT PRIMARY KEY AUTO_INCREMENT COMMENT '主键编号',
user_name VARCHAR(50) COMMENT '账号',
user_pwd VARCHAR(50) COMMENT '密码',
begin_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time TIMESTAMP COMMENT '修改时间'
) COMMENT '用户表' ENGINE = INNODB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;