找不到Postgresql列,但在Describe中显示

时间:2012-05-16 07:32:45

标签: sql postgresql quoted-identifier

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

我正在尝试在表上进行简单的选择,只检索一列。该列显示在describe表中,但是当我尝试选择它时,我得到一个未找到列的错误。我正在使用命令行界面。

表格

 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

选择:

select `transactionAmount` from ... where ... group by transactionAmount;

错误:

ERROR:  column "transactionamount" does not exist
LINE 1: select `transactionAmount` from ... where...

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

1 个答案:

答案 0 :(得分:2)

为什么在列名中使用`

您可以在没有任何引号字符的情况下使用它,而对于引号字符,它可能区分大小写。此类引用char也是",而不是`

所以使用:

select "transactionAmount" 
from ... 
where ... 
group by "transactionAmount";

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html

了解标识符