【问题标题】:postgresSQL: column doesn't exist, when trying to insert into table [duplicate]postgresQL:尝试插入表时,列不存在[重复]
【发布时间】:2021-12-01 14:48:06
【问题描述】:

当我在终端运行时:

INSERT INTO signup (username, user_password) VALUES("John", "dqw1");

它给了我:错误:列“约翰”不存在。

这可能是什么问题?这甚至没有意义,列名是用户名。 "John" 只是一个值,它之前不应该存在。

【问题讨论】:

  • 用单引号代替双引号

标签: sql postgresql string-constant


【解决方案1】:

问题在于双引号 - postgres 将它们解释为“分隔标识符”(即对象的名称,例如表中的列)。

所以不要这样:

INSERT INTO signup (username, user_password) VALUES("John", "dqw1");

这样做:

INSERT INTO signup (username, user_password) VALUES('John', 'dqw1');

【讨论】:

  • 这是一个常见问题解答 - 将其作为副本关闭会更有用。此行为由 SQL 标准规定。
猜你喜欢
  • 2021-09-24
  • 2021-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-18
  • 1970-01-01
相关资源
最近更新 更多