mysql中插入和显示中文字符问题

来源:互联网 发布:网络诈骗的款能追回吗 编辑:程序博客网 时间:2024/05/17 21:58

     使用utf8编码直接建立数据库无法插入中文,需要做些调整。用set names '字符集' 将character_set_client、 character_set_results和character_set_connection设置为GBK,需要插入中文的列声明为varchar类型即可插入中文字符。格式为:

set names='字符集' 

例如:

create table if not exists customer
 (
   SFZH char(18) not null unique,
   XM   varchar(30),
   ZH   char(16) not null
 );

 

delete from customer;
insert
into customer
values('123456781234567890','刘平,'6224321207808899');

 

      可以用show variables like 'character%'查看字符集情况。

原创粉丝点击