Detecting utf8 broken characters in MySQL(在 MySQL 中检测 utf8 损坏的字符)
问题描述
我有一个数据库,其中有一堆散落在多个表中的损坏的 utf8 字符.字符列表不是很广泛 AFAIK (áéíúóÁÉÍÓÚÑñ)
I've got a database with a bunch of broken utf8 characters scattered across several tables. The list of characters isn't very extensive AFAIK (áéíúóÁÉÍÓÚÑñ)
修复给定的表非常简单
update orderItem set itemName=replace(itemName,'á','á');
但是我无法找到检测损坏字符的方法.如果我做类似的事情
But I can't get a way of detecting the broken characters. If I do something like
SELECT * FROM TABLE WHERE field LIKE "%Ã%";
由于排序规则 (Ã=a),我获得了几乎所有字段.到目前为止,所有损坏的字符都以Ã"开头.数据库是西班牙语的,所以不使用这个特定的字符
I get nearly all the fields because of the collation (Ã=a). All broken characters so far start with an "Ã". The database is in spanish so this particular character isn't used
到目前为止我得到的损坏字符列表是
The list of broken chars I've got so far is
á = á
é = é
Ã- = í
ó = ó
ñ = ñ
á = Á
知道如何使这个 SELECT 按预期工作吗?(二进制搜索或类似的东西)
Any idea of how to make this SELECT to work as intended? (a binary search or something like that)
推荐答案
另一种方法如何,即来回转换列以获得正确的字符集?您可以将其转换为二进制,然后转换为 utf-8,然后转换为 iso-8859-1 或您正在使用的任何其他内容.有关详细信息,请参阅手册.
How about a different approach, namely converting the column back and forth to get the correct character set? You can convert it to binary, then to utf-8 and then to iso-8859-1 or whatever else you're using. See the manual for the details.
这篇关于在 MySQL 中检测 utf8 损坏的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 MySQL 中检测 utf8 损坏的字符
基础教程推荐
- 在 SQL 中连接多个表 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
