未找到 Postgresql 列,但在描述中显示

hgo*_*lov 2 sql postgresql quoted-identifier

有类似的帖子,但没有一个能帮助我解决我的问题。

我正在尝试对表进行简单的选择,仅检索一列。该列显示在描述表中,但是当我尝试选择它时,出现“未找到列”错误。我正在使用命令行界面。

桌子:

 id                        | integer                  | not null default 
 amazon_payment_id         | integer                  | not null
 source                    | character varying(10)    | not null
 timestamp                 | timestamp with time zone | not null
 status                    | character varying(50)    | not null
 statusReason              | character varying(100)   | not null
 transactionId             | character varying(50)    | not null
 transactionDate           | timestamp with time zone | 
 transactionAmount         | numeric(6,2)             | 
 errorMessage              | character varying(100)   | not null
Run Code Online (Sandbox Code Playgroud)

ETC。

选择:

select `transactionAmount` from ... where ... group by transactionAmount;
Run Code Online (Sandbox Code Playgroud)

错误:

ERROR:  column "transactionamount" does not exist
LINE 1: select `transactionAmount` from ... where...
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么我会收到此错误?

Mic*_*las 5

`为什么在列名中使用?

您可以在不使用任何引号字符的情况下使用它,而使用引号字符时可能会区分大小写。同样这样的引用字符是", 而不是`

所以使用:

select "transactionAmount" 
from ... 
where ... 
group by "transactionAmount";
Run Code Online (Sandbox Code Playgroud)

阅读有关标识符的信息:http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html