如何在整个数据库中更改CHARACTER SET(和COLLATION)? [英] How to change the CHARACTER SET (and COLLATION) throughout a database?

查看:138
本文介绍了如何在整个数据库中更改CHARACTER SET(和COLLATION)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们以前的程序员在表(Mysql)中设置了错误的排序规则.他使用拉丁文归类(应为UTF8)进行设置,现在我遇到了问题.每个带有中文和日文字符的记录都变成???字符.

Our previous programmer set the wrong collation in a table (Mysql). He set it up with Latin collation, when it should be UTF8, and now I have issues. Every record with Chinese and Japan character turn to ??? character.

是否可以更改排序规则并找回字符的详细信息?

Is possible to change collation and get back the detail of character?

推荐答案

更改数据库排序规则:

ALTER DATABASE <database_name> CHARACTER SET utf8 COLLATE utf8_unicode_ci;

更改表排序规则:

ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

更改列排序规则:

ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

更多信息:

  • What are the diffrences between utf8_general_ci and utf8_unicode_ci?
  • What's the difference between utf8_general_ci and utf8_unicode_ci
  • How to change collation of database, table, column?

这篇关于如何在整个数据库中更改CHARACTER SET(和COLLATION)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆