【问题标题】:Postgresql Column Not Found, But Shows in Describe未找到 Postgresql 列,但在描述中显示
【发布时间】:2012-05-16 07:32:44
【问题描述】:

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

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

表格:

 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...

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

【问题讨论】:

    标签: sql postgresql quoted-identifier


    【解决方案1】:

    为什么在列名中使用`

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

    所以使用:

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

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

    【讨论】:

    • 谢谢。作为最后的手段,我尝试了反引号,我没有想到双引号。双引号为我修复了它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 2020-09-15
    • 1970-01-01
    • 2015-04-18
    • 1970-01-01
    • 2018-12-05
    相关资源
    最近更新 更多