2017-09-15 44 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

相關問題