mysql database character set, character set tables, columns, character set priority, and modify the table character set utf8 is whether the data before the impact of utf8mb4 abbreviated

myslq may be provided at the database level, table level, the column level character set encoding;

Order of priority: the database character set <character set table <column character set;

That is inconsistent levels of the above three character sets, to configure a smaller range of subject;

For example: a database default character set is utf8 case utf8 character sets do not set the table, if the table automatically set the encoding utf8mb4; then the character set encoding on the table for the utf8MB4;

 

 

Because there will be rare words after being given the lead storage, data storage failure; so I decided most of the data from the table utf8 changed utf8mb4, began to think of two questions:

1, when a transcoding table, if the table after a transfer field length exceeds the maximum length setting 255, code conversion table is not successful, the data will be successful or abnormal; 2, code conversion, the byte length the changes may result in the original normal character memory 255 are now not stored properly preventing portion of the original can be stored field data, now stored length becomes short to the storage;

 

Later, through the test to get the answer - no effect;

The first point. Mysql version 5.0 or higher because, varchar (255), 255 refers to a character; Maximum 65532 bytes; therefore varchar (255) change the character set even though this limit, no more than the maximum number of bytes, it will not be affected;

The second point: the character set to modify the table, they can choose whether to refresh existing data (whether with a new character set is stored); or only take effect on the later insertion of data (existing data without processing);

Statements are as follows:

1 Before you modify the table's character set and refresh existing data; you can see three records after modifying the existing affected; (if you need to set behind the collation increase COLLATE collation    can)

The Table the ALTER table_name CONVERT to the SET CHARACTER   new character sets

2 character set changes to the table, but not before existing data refresh; you can see after modify the affected behavior 0; (if you need to set behind the collation increase COLLATE collation    can)

The Table the ALTER table_name the DEFAULT to the SET CHARACTER   new character sets

 

Published 301 original articles · 197 won praise · views 270 000 +

Guess you like

Origin blog.csdn.net/boss_way/article/details/103033018