首页 > 解决方案 > Oracle SQL - 查找和替换 ASCII

问题描述

在我的数据库中,使用这些 ASCII 值插入了特殊字符

ASCII(' ')  ASCII('')   
49828          32     

列描述中显示的ASCII 值49828显示为特殊字符¤

如何找到所有具有此特殊字符的值?以及如何用常规空格替换它(ASCII 32)

标签: sqloracleascii

解决方案


我会说你会使用REPLACE(如你所说)。

样品表:

SQL> create table test (col) as
  2  select 'x' || chr(67)    || 'y' from dual union all
  3  select 'x' || chr(49828) || 'y' from dual;

Table created.

内容(忽略我的SQL*Plus 和我的数据库Ą中显示的内容):

SQL> select * from test;

COL
----
xCy
xĄy

仅更新包含该值的行:

SQL> update test set
  2    col = replace(col, chr(49828), chr(32))
  3    where instr(col, chr(49828)) > 0;

1 row updated.

结果:

SQL> select * from test;

COL
----
xCy
x y

SQL>

推荐阅读