请问我写的sql报错语法错误是为什么?

来源:4-1 数据库设计与编码

CGJ_M

2017-04-02 23:55

mysql> create table seckill(

    -> seckill_id bigint not null AUTO_INCREMENT,

    -> name varchar(120) not null,

    -> number int not null,

    -> start_time timestamp not null default CURRENT_TIMESTAMP,

    -> end_time timestamp not null default CURRENT_TIMESTAMP,

    -> create_time timestamp not null default CURRENT_TIMESTAMP,

    -> primary key (seckill_id),

    -> key idx_start_time(start_time),

    -> key idx_end_time(end_time),

    -> key idx_create_time(create_time)

    -> )ENGINE=InnoDB AUTO_INCREMENT=1000 default charset=utf8;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURRENT_TIMESTAMP,

end_time timestamp not null default CURRENT_TIMESTAMP,

cr' at line 5


写回答 关注

2回答

  • 暴走的大猩猩
    2017-04-03 10:14:11
    已采纳

    CREATE TABLE seckill (
     `seckill_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '商品库存ID',
     `name` VARCHAR (120) NOT NULL COMMENT '商品名称',
     `number` INT NOT NULL COMMENT '库存数量',
     `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `start_time` TIMESTAMP NOT NULL COMMENT '秒杀开启时间',
     `end_time` TIMESTAMP NOT NULL COMMENT '秒杀结束时间',
     PRIMARY KEY (seckill_id),
     KEY idx_start_time (start_time),
     KEY idx_end_time (end_time),
     KEY idx_create_time (create_time)
    ) ENGINE = INNODB AUTO_INCREMENT = 1000 DEFAULT CHARSET = utf8 COMMENT = '秒杀库存表' ;

    690017... 回复Bruce_...

    alt+96

    2017-12-11 16:32:47

    共 3 条回复 >

  • 暴走的大猩猩
    2017-04-03 10:14:55

    create_time 放在start_time前面

Java高并发秒杀API之业务分析与DAO层

Java实现高并发秒杀API的第一门课,还等什么,赶快来加入吧

87424 学习 · 496 问题

查看课程

相似问题