PostgreSQL:获取所有包含大写字母的行

ifn*_*tak 0 sql database string postgresql where-clause

我怎样才能做到以下 stmt:

select * from table
where column has any uppercase letters; <-- how to write this
Run Code Online (Sandbox Code Playgroud)

GMB*_*GMB 5

您可以使用正则表达式进行过滤:

select * 
from mytable
where mycolumn ~ [A-Z]
Run Code Online (Sandbox Code Playgroud)

另一种方法是字符串比较:

select * 
from mytable
where lower(mycolumn) <> mycolumn
Run Code Online (Sandbox Code Playgroud)

  • 在正则表达式示例中,模式必须包含单引号:mycolumn ~ '[AZ]' (3认同)