[MySQL] - Change the MySQL syntax errors in the coding of a table column

  Encoding MySQL, the commonly used gb2312 <gbk <utf8.

  View MySQL encoding, commonly used three parameters: character_set_client, character_set_connection, character_set_result.

         

  

  Queries goods table coding situations column: show full columns from goods;

  

 

 

 

  In the case where the same three parameters, the value found in the table goods_name goods are cut off, when a separate insert a row, an error message character encoding.

      

 

 

   

  Use alter table change syntax to modify the default character set of columns, the result of an error ERROR 1064. own syntax did not find what is wrong.

    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>

  

  Later, after removing the not null, find the update statements can update the character set to normal

  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

  

  

  

 

Guess you like

Origin www.cnblogs.com/gaochsh/p/12398243.html