Mysql报错1293 Incorrect table definition. there can be only one timestamp column with current_timestam

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或者小海豚。
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值