在整个数据库中搜索乱码`�` - Oracle
最近,我们通过确保文件为 UTF-8 并且 Java 代码以 UTF-8
编码打开这些文件,解决了字符编码从文本文件错误读入系统的问题。
然而,我们最终在整个数据库表中添加了许多记录,并插入了错误的字符,即 °F
被读取为 �F
。因此,即使我们现在已经解决了这个问题,我们现在也需要清理数据库表来纠正这个异常。
谁能建议我实现这一目标的方法吗?
We recently fixed an issue with the character encoding being read incorrectly into our system from the text files by making sure the file is UTF-8 and the Java code opens these files in UTF-8
encoding.
However, we had ended up adding a lot of records across the entire database tables with incorrect characters being inserted i.e. °F
was read as �F
. So even though we have fixed this now, we need to clean up the database tables now to rectify this anomaly.
Can anyone please suggest me ways to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不久前我也遇到了类似的问题。幸运的是,它影响的列数仅限于少数,并且这些列在整个数据库中具有相同的名称。
我通过编写一个执行以下操作的脚本解决了这个问题:
目标列
REGEXP_REPLACE
这使用健康剂量的动态 SQL,从
user_constraints
和user_tab_columns
中提取数据,过滤我所针对的特定列名称。这是一个帮助您入门的粗略框架,我只是快速地将其组合在一起,因此没有经过测试。另外,如果您需要担心触发器,您也需要禁用它们:
I had a similar problem a while back. Luckily, the number of columns that it affected was limited to a small number, and those columns had the same name throughout the database.
I solved this by writing a script that does the following:
target columns
REGEXP_REPLACE
This used a healthy dose of dynamic SQL, pulling data from the
user_constraints
anduser_tab_columns
, filtering on the specific column names I was targeting.Here's a rough skeleton to get you started, I've just thrown it together quickly, so it isn't tested. Also, if you have triggers to worry about, you'll need to disable those too: