Ways to modify the encoding of fields in tables and tables in a MySQL database

Source: Internet
Author: User

Today to the MySQL database to add a table containing Chinese data, but always out of the exception, check the program did not find errors, helpless Ah, and then re-check the table found that the table is encoded latin1 and the original thought can be inserted in the Chinese field encoding is also latin1, Then again carefully observe the console output of the exception, further determined that the table and the table in the wrong field coding, then modify the table and the corresponding fields in the net for a while, you don't say there is really, after the execution of SQL script can be deposited in Chinese, although so still think it is necessary to summarize, The Ancients cloud: good memory is better than bad writing, oh ah.

Modify table Encoding: ALTER table ' Test ' DEFAULT CHARACTER SET UTF8; This command is used to change the encoding of the table test to UTF8;

To modify the encoding of a field: ALTER TABLE ' test ' change ' name ', ' name ' VARCHAR (CHARACTER) SET UTF8 not NULL; This command is used to change the encoding of the Name field in the table test to UTF8

Source: http://www.jb51.net/article/50091.htm

Ways to modify the encoding of fields in tables and tables in a MySQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.