• mysql 向表中插入数据报1366


    当我们在向mysql中的表中插入数据报了这个一个错误

    1366 - Incorrect string value: 'xE4xBAxBAxE4xBAx8B...' for column 'dname' at row 1

    mysql> use test;
    Database changed
    mysql> INSERT INTO department(did,dname) VALUES(1,'人事部');
    1366 - Incorrect string value: 'xE4xBAxBAxE4xBAx8B...' for column 'dname' at row 1
    mysql> INSERT INTO department(did,dname) VALUES(1,'人事部');
    1366 - Incorrect string value: 'xE4xBAxBAxE4xBAx8B...' for column 'dname' at row 1

    是因为在建表的时候没有使用中文编码,所有存不了相应的中文数据

    我们把原来的表删除。重新建表

    mysql> CREATE TABLE department( 
    did INT(4) PRIMARY KEY,
    dname VARCHAR(36) NOT NULL )
    default charset=utf8 ;
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> CREATE TABLE employee
    (id INT(4) PRIMARY KEY,
    NAME VARCHAR(36) NOT NULL,
    age INT(2) NOT NULL,
    did INT(4)
    )default charset=utf8 ;
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> INSERT INTO department(did,dname) VALUES(1,'人事部');
    Query OK, 1 row affected (0.01 sec)
    
    mysql> INSERT INTO department(did,dname) VALUES(2,'院校产品部');
    INSERT INTO department(did,dname) VALUES(3,'咨询部');
    Query OK, 1 row affected (0.00 sec)
    
    Query OK, 1 row affected (0.00 sec)
    
    mysql> INSERT INTO employee(id,NAME,age,did) VALUES(1,'张三',20,1);
    INSERT INTO employee(id,NAME,age,did) VALUES(2,'李四',35,2);
    INSERT INTO employee(id,NAME,age,did) VALUES(3,'王五',19,3);
    Query OK, 1 row affected (0.01 sec)
    
    Query OK, 1 row affected (0.00 sec)
    
    Query OK, 1 row affected (0.00 sec)

    这样问题就解决了!!

  • 相关阅读:
    回溯法之图的着色问题
    回溯法基本思想
    L2-006 树的遍历
    P1540 机器翻译
    P1067 多项式输出
    C++STL之map映照容器
    C++STL之multiset多重集合容器
    C++STL之set集合容器
    C++之string基本字符系列容器
    C++STL之vector向量容器
  • 原文地址:https://www.cnblogs.com/braveym/p/14002859.html
Copyright © 2020-2023  润新知