1、已建立的表无法插入中文字符串,原因是因为数据表中的内容为latin1字符集,由下图的的资料可知,latin1字符集为8bit,这说明它是不能表示中文的,故而当然会报改错:
2、下面是具体问题,如果不修改name的字符集latin1,插入中文给name时,将会报错 Incorrect string value: '\xE7\x8E\x8B\xE6\x9E\x97',下图改了name,没有改education,故而name没有报错,是education报错 :
3、一些关于查看和修改字符集的mysql知识:
查看mysql的字符集:show variables where Variable_name like '%char%';
查看某一个数据库字符集:show create database enterprises;(注:enterprises为数据库)
查看某一个数据表字符集:show create table employees;(注:employees为数据表)
修改mysql的字符集:
mysql> set character_set_client=utf8;
mysql> set character_set_connection=utf8;
mysql> set character_set_database=utf8;
mysql> set character_set_results=utf8;
mysql> set character_set_server=utf8;
mysql> set character_set_system=utf8;
mysql> set collation_connection=utf8;
mysql> set collation_database=utf8;
mysql> set collation_server=utf8;
修改数据库enterprises的字符集:
alter database enterprises character set utf8
修改数据表employees的字符集:
alter table employees character set utf8
修改字段的字符集
alter table employees change name name char(10) character set utf-8;