mysql-charset

If the user wants to change the default character set of the table and the character set of all character columns to a new character set, use the following statement: 
ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name; 

Warning: 
The above operation converts column values ​​in the character set. If the user has a column in a character set (such as gb2312), but the stored value uses some other incompatible character set (such as utf8), then the operation will not get the result the user expects. In this case, the user must do the following for each column: 

ALTER TABLE t1 CHANGE c1 c1 BLOB; 
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8; 

The reason for this is: Converting from or to a BLOB column does not Conversion happens. 

If the user specifies CONVERT TO CHARACTER SET in binary, 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 act on them. 

To change only the default character set for a table, use the following statement: 

ALTER TABLE tbl_name DEFAULT CHARACTER SET charset_name; 

DEFAULT is optional. When adding a new column to a table, if no character set is specified, the default character set is used (eg when ALTER TABLE ... ADD column). 

ALTER TABLE ... DEFAULT CHARACTER SET and ALTER TABLE ... CHARACTER SET are equivalent, modifying only the default table character set.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326253189&siteId=291194637