mysql - How to change collation of all rows from latin1_swedish_ci to utf8_unicode_ci? -
i ignorantly used default latin1_swedish_ci character encoding of varchar rows in database during development , i've determined root of character encoding problems i've been having. in addition that, seems people these days recommending utf8_unicode_ci used.
i'd convert character encoding rows in database latin1_swedish_ci utf8_unicode_ci, way know how is change row-by-row in phpmyadmin, time consuming.
is there faster way, such query can run changes collation of varchar/text rows latin1_swedish_ci utf8_unicode_ci?
if columns using default table character set it's 1 query per table convert:
alter table t convert character set utf8 collate utf8_unicode_ci;
if character set set individually on each column, afaik there no way on columns of tables in database directly in mysql, write tiny program in language of choice so.
your program query information_schema.columns
table , @ character_set_name
column:
select * `information_schema.columns` table_schema = 'dbname' , character_set_name = 'latin1'
for each result row it's trivial synthesize , execute alter table
query on spot changes character set , collation appropriately:
alter table t modify col text character set utf8 collate utf8_unicode_ci;
in above query t
, col
, text
values of table_name
, column_name
, data_type
columns information_schema.columns
result set.
Comments
Post a Comment