PostgreSQL - 插入语句错误,认为要插入的值是列名 [英] PostgreSQL - insert statement error, thinks value to insert is a column name

查看:45
本文介绍了PostgreSQL - 插入语句错误,认为要插入的值是列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Mac 上运行 PostgreSQL 版本 9.5.1 - 我试图做一个简单的插入语句,但它吐出一个我不太明白的错误......出于某种原因,它似乎认为我插入的值之一实际上是列名之一.这是场景...

I'm running PostgreSQL version 9.5.1 on my Mac - I'm trying to make a simple insert statement, but it's spitting an error that I don't quite understand... for some reason, it seems to think that one of the values that I'm inserting is actually one of the column names. Here's the scenario...

\d+ group_members

Column      |            Type             |
------------+-----------------------------+
id          | integer                     |
group_id    | integer                     |
user_id     | integer                     |
role        | character varying(255)      |
inserted_at | timestamp without time zone |
updated_at  | timestamp without time zone |

Indexes:
  "group_members_pkey" PRIMARY KEY, btree (id)
  "group_members_group_id_index" btree (group_id)
  "group_members_user_id_index" btree (user_id)

当我尝试跑步时

insert into group_members (group_id, user_id, role, inserted_at, updated_at)
values (1, 2, ’member’, current_timestamp, current_timestamp);

我收到错误:

ERROR:  column "’member’" does not exist
LINE 1: ...user_id,role,inserted_at,updated_at) values (1,2,’member’,c...
                                                            ^

嗯,是的,我同意,成员"列不存在......但我不确定我是否理解为什么 PostgreSQL 认为这是我的意图.我已经在其他表中进行了多次插入,现在遇到了这样的问题,但我似乎无法插入到这个表中.谁能看到我哪里出错了?

Well yes, I agree, the column 'member' does not exist... but I'm not sure I understand why PostgreSQL thinks that this is my intention. I have made numerous inserts into other tables and had now such problem but I can't seem to insert into this table. Can anyone see where I've gone wrong?

推荐答案

'member' 替换 'member' .

您似乎没有单引号.它是其他一些字符

It seems you dont have single quote. it is some other char

这篇关于PostgreSQL - 插入语句错误,认为要插入的值是列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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