【问题标题】:INSERT COMMAND :: ERROR: column "value" does not exist插入命令 :: 错误:列“值”不存在
【发布时间】:2016-10-15 10:10:16
【问题描述】:

我正在使用 postgresql,我正在尝试将数据插入到表 users 中。当我使用

INSERT INTO users(user_name, name, password,email) VALUES ("user2","first last","password1", "user2@gmail.com" );

我收到以下错误:

ERROR:  column "user2" does not exist

这就是表格的样子。

Table "public.users"
  Column   |       Type    |  Modifiers                        
 user_name | character varying(50)  | 
 name      | character varying(50)  | 
 password  | character varying(50)  | 
 email     | character varying(100) | 
 user_id   | integer                | not null default nextval('users_user_id_seq'::regclass)
Indexes:
    "users_pkey" PRIMARY KEY, btree (user_id)

我可以插入一行,但现在无法正常工作。

【问题讨论】:

标签: sql postgresql


【解决方案1】:

字符常量需要单引号

使用:INSERT INTO users(user_name, name, password,email) VALUES ('user2','first last','password1', 'user2@gmail.com' );

查看手册:postgresql.org/docs/current/static/…

注意:由于@a-horse-with-no-name,我遇到了同样的问题并且几乎错过了此页面中存在的答案(在 cmets 部分) - 我已经发布了这个答案

【讨论】:

  • 我遇到了很多糟糕的错误信息,但是这个很有趣。我很确定我会在一两年内再次来到这里。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多