zoukankan      html  css  js  c++  java
  • [MySQL]--MySQL表中某个列插入数据总被截断,报编码方式的语法错误,实际是column的not null属性和更改编码语法导致的冲突。

      MySQL的编码方式中,常用的有gb2312<gbk<utf8。

      MySQL的编码方式的查看,常用三个参数:character_set_client, character_set_connection ,character_set_result.

             

      

      查询goods表的列的编码情况: show full columns from goods;

      

      在三个参数一样的情况下,发现goods表中的goods_name的值被截断了,单独插入一行数据的时候,报字符编码错误。

          

       

      用alter table change语法来修改列的默认字符集,结果报错ERROR 1064. 自己没发现语法错在什么地方。

        mysql> alter table goods change goods_name goods_name varchar(120) not null character set utf8 ;
        ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'character set utf8' at line 1
        mysql>

      

      后来去掉了not null之后,发现更新字符集语句可以正常更新了

      mysql> alter table goods change goods_name goods_name varchar(120) not null character set utf8 ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'character set utf8' at line 1
      mysql>
      mysql>
      mysql>
      mysql> alter table goods change goods_name goods_name varchar(120) character set utf8 ;
      Query OK, 0 rows affected (0.08 sec)
      Records: 0 Duplicates: 0 Warnings: 0

      

      

      

  • 相关阅读:
    C# 特性(Attribute)学习
    ASP.NET Request.MapPath() 与 Server.MapPath()
    Asp.net对http request 处理的全过程!
    保存网址
    寻找silverlight高手帮忙解决问题,谢谢,
    基于.Net Framework的N层分布式应用开发
    VB.NET 代码转为C#
    刚刚开通博客噢 。欢迎大家光临啊
    配置本地服务器的几种方式
    前端必备工具 (记录)
  • 原文地址:https://www.cnblogs.com/gaochsh/p/12398243.html
Copyright © 2011-2022 走看看