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

插入数据报错

cha插入数据报错: Incorrect string value: '\xF0\x9F...' for column 'XXX' at row 1 有没有和我一样的呢?

提问者:慕函数1123206 2018-01-25 19:29

个回答

  • 叶0528
    2019-05-17 17:47:04

    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>


  • jy_li
    2018-06-20 21:23:12

    你是不是把create_time也加上去了,导致前后列数不一样,比如insert into 表名 (field1,field2,field3) values('a','b')这样前面的是三列,后面却只有二个值,这就会出现这个错误的。

  • 大叔_fighting
    2018-01-27 18:52:49

    表 列名不对应吧