How does MySQL modify the character set of a table and the character set of a field?

Source: Internet
Author: User

How does MySQL modify the character set of a table and the character set of a field? If you want to change the character set of the table's default character set and all character columns to a new one, use the following statement: alter table tbl_name convert to character set charset_name; warning: the above operation is to convert column values in the character set. If you have a column in a character set (such as gb2312), but the stored values use other incompatible character sets (such as utf8 ), the operation will not get the expected results. In this case, you must perform the following operations on each column: alter table t1 CHANGE c1 c1 BLOB; alter table t1 CHANGE c1 c1 text character set utf8; the reason is: conversion from a BLOB column or to a BLOB column does not occur. If you specify convert to character set in BINARY format, the CHAR, VARCHAR, and TEXT columns are converted TO their corresponding BINARY string types (BINARY, VARBINARY, BLOB ). This means that these columns will no longer have character sets, and subsequent convert to operations will not work on them. If you only change the default character set of a TABLE, use the following statement: alter table tbl_name default character set charset_name; DEFAULT is optional. When a new column is added to a TABLE, if no character set is specified, the default character set is used (for example, when alter table... ADD column ). Alter table... default character set is equivalent to alter table... character set. Only the default table character set is modified.

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.