01| 出现的问题
- 环境:IDEA 2017.2 mysql 5.5.0
- 建表时,数据库提示 错误代码: 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause。相应的发生异常的sql语句如下:
create table `admin_info` ( `admin_id` int not null auto_increment, `username` varchar(32) not null, `password` varchar(32) not null, `phone` varchar(64) not null comment '用户手机号', `admin_type` int not null comment '1员工,2管理员', `create_time` timestamp not null default current_timestamp comment '创建时间', `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', primary key (`admin_id`) ) comment '餐厅卖家信息表';
02 | 错误原因
- 翻阅了资料才知道,mysql 5.5 只能有一个Timestamp,而我上面的sql语句中出现了两个,所以报错,而只要mysql5.6以上版本就可以了。
03 | 解决办法
- 法一: 将其中一列类型改为datetime类型就可以解决。
- 法二: 对mysql进行升级。
- 此处,我选择了第二种方法,对mysql5.5进行卸载,重新下载mysql8,因为IDEA中可以进行数据库可视化操作,所以没有安装navicat或者小海豚。