为什么 postgresql 不能执行其 'where' 子句具有键匹配谓词的 select 语句?


select * from note where noteKey = 1

此语句给我以下错误。

ERROR:  column "notekey" does not exist
LINE 1: select * from note where noteKey = 1
                                 ^
HINT:  Perhaps you meant to reference the column "note.noteKey".

我尝试了Note.notekey,但有同样的错误。(顺便说一句,我使用了postico,而notekey是表注的主要键)。

该语句可能有什么问题?

您需要与PSQL连接并运行d note

如果该列显示了用大写K称为noteKey,则您有两个选项

  1. 重命名列ALTER TABLE note RENAME COLUMN "noteKey" TO notekey;
  2. 永远使用双引号 "对其进行查询。

在postgresql中,我们从不引用列名。这迫使他们对帽子敏感。当不引用时,它们会自动降低壳体。

这个

select * from note where noteKey = 1

相同
select * from note where notekey = 1

不同
select * from note where "noteKey" = 1

最新更新