“user”PostgreSQL附近的语法错误,即使引用了用户

问题描述 投票:0回答:2

在postgres上获取此信息:

syntax error at or near ""user""

对于以下内容:

insert into "user" ("id", "email") values ('1', '[email protected]') on conflict do update "user" set "id" = '1', "email" = '[email protected]'

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

postgresql syntax-error
2个回答
2
投票

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

insert into "user" ("id", "email") values ('1', '[email protected]')
on conflict do update set "id" = '1', "email" = '[email protected]'

syntax here

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

1
投票

"user"之后删除ON CONFLICT DO UPDATE

© www.soinside.com 2019 - 2024. All rights reserved.