且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Postgres列或表名称何时需要加引号,什么时候不需要引号?

更新时间:2022-06-01 09:16:01

感谢@TimBiegeleisen的评论,我能够找到问题所在。我使用保留关键字(用户)作为列名。

Thanks to @TimBiegeleisen's comment, I was able to pinpoint the problem; I used a reserved keyword ("user") as a column name.

链接到文档中的保留关键字: https://www.postgresql.org/docs/current/sql-keywords-appendix.html

Link to reserved keywords in the doc: https://www.postgresql.org/docs/current/sql-keywords-appendix.html.

现在知道不要使用引号来查询列名,而要避免使用保留关键字作为列名。

Now I know not to use quotes to query column names, but rather to avoid reserved keywords as column names.