postgresql - "user"PostgreSQL 附近的语法错误,即使引用了用户

标签 postgresql syntax-error

在 postgres 上获取这个:

syntax error at or near ""user""

对于以下内容:

insert into "user" ("id", "email") values ('1', 'foo@example.com') on conflict do update "user" set "id" = '1', "email" = 'foo@example.com'

玩了一段时间,不知道语法错误在哪里。感谢您的帮助。

最佳答案

显然,您不能在 ON CONFLICT UPDATE SET 子句中指定表名。以下似乎有效:

insert into "user" ("id", "email") values ('1', 'foo@example.com')
on conflict do update set "id" = '1', "email" = 'foo@example.com'

syntax here :

....
DO UPDATE SET { column_name = { expression | DEFAULT } |
                ( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] ) |
                ( column_name [, ...] ) = ( sub-SELECT )
              } [, ...]
          [ WHERE condition ]

关于postgresql - "user"PostgreSQL 附近的语法错误,即使引用了用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47850268/

相关文章:

syntax-error - 液体警告: Unexpected character

class - 有2个参数的Property Let有什么问题?

python - 为什么我不能分配给命名表达式(LHS 海象运算符)?

java - JPA 和 Postgres generate_series

postgresql - BIRT 报告 postgreSQL DB 上的异常

postgresql - postgres 和 docker-compose : can't create a custom role and database

sql - 查找并删除可以在两列之间交换值的重复条目

ruby-on-rails - 在HAML中,语法错误,意外的 ')'不是我放置的

sql - 更优雅的批量验证电话号码的方法

php - 尝试将正则表达式匹配传递给函数时出错