數(shù)據庫
中文亂碼
postgre
最近使用hive往postgre傳輸數(shù)據后,發(fā)現(xiàn)postgre中包含亂碼,所以想找到對應的行并刪除纹蝴。
網上找了好久载庭,終于看到一篇文章可以用宾茂,所以記錄下來
https://blog.csdn.net/weixin_34237596/article/details/90590065
查找中文亂碼的行
select * from sap_full_year_forecast where item ~ '[\ub0a1-\uf7ff]';
postgre 中~ 的含義
操作符 ~~ 等效于 LIKE, 而 ~~* 對應 ILIKE难捌。 還有 !~~ 和 !~~* 操作符 分別代表 NOT LIKE 和 NOT ILIKE膝宁。
另外:
~ 匹配正則表達式鸦难,大小寫相關 'thomas' ~ '.*thomas.*'
~* 匹配正則表達式,大小寫無關 'thomas' ~* '.*Thomas.*'
!~ 不匹配正則表達式员淫,大小寫相關 'thomas' !~ '.*Thomas.*'
!~* 不匹配正則表達式合蔽,大小寫無關 'thomas' !~* '.*vadim.*'
image.png
查找中文行
select * from sap_full_year_forecast where hotel_code = 'WUHMA' and item ~ '[\u2e80-\ua4cf]|[\uf900-\ufaff]|[\ufe30-\ufe4f]';
image.png
本文中我只是在使用postgre 數(shù)據庫,沒有測試MySQL 和oracle,但大體思路應該是一致的吧介返。