插入命令::错误:列“值”不存在 [英] INSERT COMMAND :: ERROR: column "value" does not exist

查看:86
本文介绍了插入命令::错误:列“值”不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用postgresql,并且试图将数据插入表 users 中。当我使用

I am using postgresql and I am trying to insert data into a table users. When I do that using

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)

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

I was able to insert a row, but it is not working now.

推荐答案

字符常量需要单引号

使用:插入用户(用户名,名称,密码,电子邮件)值('user2','first last','password1','user2@gmail.com');

请参见手册:< a href = https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS rel = noreferrer> postgresql.org/docs/current/static/ …

注意:在我遇到相同的问题并且几乎错过了该页面上存在的答案(在评论部分)之后,由于@ a-horse-with-no-name-我已经发布了这个答案

这篇关于插入命令::错误:列“值”不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆