MYSQL查询更改所有排序规则

时间:2015-08-22 13:38:38

标签: mysql phpmyadmin

我有一个表,所有Collat​​ion都设置为latin1_swedish_c,我需要将它们全部更改为utf8_unicode_ci并设置所有newone

是否有SQL语句,因为我已经尝试了

ALTER DATABASE  'empinity' convert TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

1 个答案:

答案 0 :(得分:0)

尝试这种方式:

ALTER TABLE `your table` CHANGE `table_field` `table_field` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci ;

对于数据库:

ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_unicode_ci;

要将所有表的排序规则更改为一次,请运行查询:

SELECT CONCAT("ALTER TABLE ", TABLE_NAME," COLLATE utf8_unicode_ci") 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="your_database_name"
AND TABLE_TYPE="BASE TABLE"