Postgres - 在列名中转义问号(?)

时间:2018-02-02 18:36:08

标签: postgresql escaping

我继承的Postgres DB中的一个列在名称中有一个问号。

当我尝试选择它时,会抛出错误

> select confirmed? from user_purchases;

ERROR:  column "confirmed" does not exist
LINE 1: select confirmed? from user_purchases;
               ^
HINT:  Perhaps you meant to reference the column "user_purchases.confirmed?".

我也试过用反引号(`确认?`)和引号(“确认?”)来选择它但是引发了同样的错误。

如何选择此字段?

谢谢!

1 个答案:

答案 0 :(得分:3)

使用双引号:

 select "confirmed?" from user_purchases;

<强> DEMO