问答详情
源自:4-1 数据库设计与编码

mysql建表时出现错误(ERROR 1067 (42000): Invalid default value for 'end_time')

https://img4.mukewang.com/5cc58d6f00015a6609460334.jpg

ERROR 1067 (42000): Invalid default value for 'end_time'

提问者:凉橙2 2019-04-28 19:25

个回答

  • 爱笑的小熊猫
    2020-08-10 05:30:45

    this error can be fixed by running 

    SET SQL_MODE='ALLOW_INVALID_DATES';


  • 旅梦人
    2019-06-12 14:53:32

    https://www.cnblogs.com/jinjiyese153/p/7300510.html

  • 叶0528
    2019-05-17 17:45:48

    mysql> insert into seckill(name,number,start_time,end_time)

        -> values

        -> ('1000元秒杀iphone6',100,'2015-11-01 00:00:00','2015-11-02 00:00:00'),

        -> ('500元秒杀ipad2',200,'2015-11-01 00:00:00','2015-11-02 00:00:00'),

        -> ('300元秒杀小米4',300,'2015-11-01 00:00:00','2015-11-02 00:00:00'),

        -> ('200元秒杀红米note',400,'2015-11-01 00:00:00','2015-11-02 00:00:00');

    ERROR 1366 (HY000): Incorrect string value: '\xC3\xEB\xC9\xB1ip...' for column 'name' at row 1

    mysql> set names 'gbk';

    Query OK, 0 rows affected (0.00 sec)


    mysql> insert into seckill(name,number,start_time,end_time)

        -> values

        -> ('1000元秒杀iphone6',100,'2015-11-01 00:00:00','2015-11-02 00:00:00'),

        -> ('500元秒杀ipad2',200,'2015-11-01 00:00:00','2015-11-02 00:00:00'),

        -> ('300元秒杀小米4',300,'2015-11-01 00:00:00','2015-11-02 00:00:00'),

        -> ('200元秒杀红米note',400,'2015-11-01 00:00:00','2015-11-02 00:00:00');

    Query OK, 4 rows affected (0.00 sec)

    Records: 4  Duplicates: 0  Warnings: 0


    mysql>


  • 干起来
    2019-04-29 00:21:42

    end_time 默认的日期 不再timestamp范围之内,默认范围是'1970-01-01 00:00:00'到2037年。