私はデータベースをutf8文字セットとutf8_unicode_ci照合に変換しています。テーブルの文字セットをutf8に変更すると、MySQLは自動的にテーブルのカラムをutf8:utf_general_ciのデフォルト照合に変換します。私は、ALTER列の数百人が、utf8_unicode_ci内にあらゆる列を変換するためのコマンドを実行したくないので、INFORMATION_SCHEMAに示すように?:utf8のMySQLのデフォルトの照合順序をutf8_unicode_ciに設定するにはどうすればよいですか?
SELECT * FROM information_schema.COLLATIONS WHERE CHARACTER_SET_NAME = 'utf8';
+---------------------------+--------------------+-----+------------+-------------+---------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN |
+---------------------------+--------------------+-----+------------+-------------+---------+
| utf8_general_ci | utf8 | 33 | Yes | Yes | 1 |
| utf8_bin | utf8 | 83 | | Yes | 1 |
| utf8_unicode_ci | utf8 | 192 | | Yes | 8 |
| utf8_icelandic_ci | utf8 | 193 | | Yes | 8 |
| utf8_latvian_ci | utf8 | 194 | | Yes | 8 |
| utf8_romanian_ci | utf8 | 195 | | Yes | 8 |
| utf8_slovenian_ci | utf8 | 196 | | Yes | 8 |
| utf8_polish_ci | utf8 | 197 | | Yes | 8 |
| utf8_estonian_ci | utf8 | 198 | | Yes | 8 |
| utf8_spanish_ci | utf8 | 199 | | Yes | 8 |
| utf8_swedish_ci | utf8 | 200 | | Yes | 8 |
| utf8_turkish_ci | utf8 | 201 | | Yes | 8 |
| utf8_czech_ci | utf8 | 202 | | Yes | 8 |
| utf8_danish_ci | utf8 | 203 | | Yes | 8 |
| utf8_lithuanian_ci | utf8 | 204 | | Yes | 8 |
| utf8_slovak_ci | utf8 | 205 | | Yes | 8 |
| utf8_spanish2_ci | utf8 | 206 | | Yes | 8 |
| utf8_roman_ci | utf8 | 207 | | Yes | 8 |
| utf8_persian_ci | utf8 | 208 | | Yes | 8 |
| utf8_esperanto_ci | utf8 | 209 | | Yes | 8 |
| utf8_hungarian_ci | utf8 | 210 | | Yes | 8 |
| utf8_sinhala_ci | utf8 | 211 | | Yes | 8 |
| utf8_german2_ci | utf8 | 212 | | Yes | 8 |
| utf8_croatian_mysql561_ci | utf8 | 213 | | Yes | 8 |
| utf8_unicode_520_ci | utf8 | 214 | | Yes | 8 |
| utf8_vietnamese_ci | utf8 | 215 | | Yes | 8 |
| utf8_general_mysql500_ci | utf8 | 223 | | Yes | 1 |
| utf8_croatian_ci | utf8 | 576 | | Yes | 8 |
| utf8_myanmar_ci | utf8 | 577 | | Yes | 8 |
+---------------------------+--------------------+-----+------------+-------------+---------+
注IS_DEFAULT
列を私は、UTF8はutf8_unicode_ci内するための既定の照合順序を設定することができます。
また、ALTER
を使用してデータベース、テーブル、またはカラムを変換する方法は問いません。
さらに、collation_server = utf8_unicode_ci
をmy.cnfに追加しても機能しません。
あなたは 'ALTER TABLE'を実行した後table_name' FROM' SHOW FULL COLUMNSを見てみる場合は、カラムの照合がutf8_general_ciで、utf8_unicode_ci内ではない... – tjbp
うーん。 ..私のために働いた。 –
奇数...以前はあなたの列はlatin1_swedish_ciでしたか? – tjbp