[英]Extract specific alphabetic characters using SQL query
Background: I am using PostgreSQL 11 on CentOS.背景:我在 CentOS 上使用 PostgreSQL 11。 I have a database having UTF-8 encoding, in specific tables I have some Latin characters as follows [ÄéÒçòý]我有一个 UTF-8 编码的数据库,在特定的表中我有一些拉丁字符如下 [ÄéÒçòý]
Objective: I want to replace those with standard English characters for that I am trying to use the following query to list down those specific characters but getting all characters set :目标:我想用标准英文字符替换那些我试图使用以下查询列出这些特定字符但设置所有字符:
SELECT name_0 from public.gadm36_0_iso2_iso3 where name_0 ~ '[[:alpha:]]';
I am searching on my side and referring to some posts as well.我在我这边搜索并参考一些帖子。
Any help/any suggestions would be great !!!任何帮助/任何建议都会很棒!!!
Perhaps you are looking for unaccent
:也许您正在寻找unaccent
:
CREATE EXTENSION unaccent;
SELECT unaccent('ÄéÒçòý');
unaccent
----------
AeOcoy
(1 row)
You can use regular expressions for this您可以为此使用正则表达式
SELECT 'ÄéÒçòý' ~* '\\A[A-Z0-9]*\\Z';
The output should be false for the above SQL statement.上述 SQL 语句的输出应为 false。 So use this in your where clause.所以在你的 where 子句中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.