Unicode Storage in MySQL
In MySQL, Unicode storage is accommodated through the use of appropriate character sets. Unlike SQL Server's nvarchar type, MySQL employs different character sets to encode data. Notably, the free edition of MySQL provides support for Unicode.
To store Unicode in MySQL, follow these steps:
-
Choose a UTF-8 Character Set:
When creating a table, specify a character set that begins with "utf8_". For example, "utf8", "utf8mb4", or "utf8mb4_0900".
-
Use Text or BLOB Data Types:
Text fields (such as TEXT, VARCHAR, and CHAR) and binary large object (BLOB) fields (such as MEDIUMBLOB and LONGBLOB) will automatically store data in UTF-8 when a UTF-8 character set is chosen for the table.
-
MySQL 6 and UTF-16 Support:
Note that UTF-16 support is still in development in MySQL. It is expected to be available in MySQL 6.
The above is the detailed content of How Do I Store Unicode Data in MySQL?. For more information, please follow other related articles on the PHP Chinese website!