Categories
Database MySQL

Change the Character Set & Collation of a table

To change the Character Set and Collation of a field of a table you have to use this query:

ALTER TABLE table_name MODIFY column_name data_type CHARACTER SET UTF8 COLLATE UTF8_UNICODE_CI;

if the table contains data, you have to update that data as follow:

UPDATE table_name SET column_name= CONVERT(CAST(CONVERT(column_name USING LATIN1) AS BINARY) USING UTF8)

Leave a Reply

Your email address will not be published. Required fields are marked *