如何在 psql 中查询。如果列名像camelCase

Moh*_*sin 2 postgresql

我的 psql 表结构如下:

id userName gender  
1   xxxx     Male
Run Code Online (Sandbox Code Playgroud)

如果我从 psql shell 使用如下查询:

select * from table where userName="xxx";
Run Code Online (Sandbox Code Playgroud)

它给出错误:错误:列“用户名”不存在。

如何查询列名是否包含带有camelCase

moh*_*mad 8

所有标识符在 postgres 中都转换为小写。要使用大写标识符,您应该在标识符周围使用双引号表示 postgres 不将其转换为小写:

select * from table where "userName" = 'xxx';
Run Code Online (Sandbox Code Playgroud)