2017-09-15 45 views
1

我有一张表格,其中包含特殊字符的记录,用于生产环境中的数据更正。现在数据库可以有包含英文或西班牙文字符的数据。所以我需要找到那些不属于这些字母的特殊字符。例如,我可以有数据如下所示:如何搜索不含英文或西班牙文字母的特殊字符的记录?

enter image description here

这里的字符Ñ是正确的,因为它是西班牙的性格,但第二个不是。我写的查询是以下内容,但是它提取了上述所有内容,而不仅仅是第二个。

select customerid,customername 
from prodschema.prodtable 
where not regexp_like(customername, '.*[^a-zA-Z0-9 .{}\[\]].*') and 
customernamelike 'YOLANDA RIOS CAS%'; 

那么对此应该是什么正确的查询?

回答

0

返回您的列客户名的ASCII值,并像那样移除。只是为了将来你可以设置列有一个强调灵敏度排序。这里

SELECT ASCII(CustomerName) 
FROM prodschema.prodtable 
WHERE ASCII(CustomerName) != Value 
2
with t as 
(
select 'YOLANDA RIOS CASTANO' str from dual 
union all select 'YOLANDA RIOS CASTAÑO' str from dual 
union all select 'YOLANDA RIOS CASTA°O' str from dual 
) 
select str, 
     length(regexp_replace(str, '[a-z[=n=] ]', null, 1, 0, 'i')) 
     as cnt_not_recognized_chars 
    from t; 

STR     CNT_NOT_RECOGNIZED_CHARS 
-------------------- ------------------------ 
YOLANDA RIOS CASTANO       
YOLANDA RIOS CASTAÑO       
YOLANDA RIOS CASTA°O      1 

3 rows selected. 

寻找更多细节http://docs.oracle.com/cd/E18283_01/server.112/e17118/ap_posix001.htm

相关问题