postgresql - 冲突 postgresql 语句与连接一起使用?

标签 postgresql

我正在使用 on conflict语句进行更新插入,但出现错误:Syntax error near to line 58: ON CONFLICT (id_producto_final) DO .

查询语句为:

     Insert into table1 (id, value1, description, isactivated)
     select a.id, b.value1, c.description, d.isactivated
     from tableA as a
     left join tableB as b on b.id=a.id1
     left join tableC as c on c.id=a.id2
     left join tableD as d on d.id=a.id3
     ON CONFLICT (id) DO UPDATE SET isactivated= EXCLUDED.isactivated

它不适用于 do nothing ,所以不是excluded table错误。所以我猜测可能加入了错误源,但我什至不知道为什么。

有人能帮忙吗?

最佳答案

https://www.postgresql.org/docs/9.5/static/sql-insert.html

ON CONFLICT can be used to specify an alternative action to raising a unique constraint or exclusion constraint violation error. (See ON CONFLICT Clause below.)

https://www.postgresql.org/docs/9.4/static/sql-insert.html - 没有这样的选择。 ON CONFLICT从9.5开始解释

https://www.postgresql.org/docs/9.5/static/release-9-5.html

Major enhancements in PostgreSQL 9.5 include:

Allow INSERTs that would generate constraint conflicts to be turned into UPDATEs or ignored

关于postgresql - 冲突 postgresql 语句与连接一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44796276/

相关文章:

sql - 基于 has_many 模型列的结果计数的 Rails 查询

postgresql - 多对多表 - 性能很差

postgresql - 如何在 Django 中禁用自动创建 ID?

postgresql - PostGres 加入 Using JSONB

python - SQLAlchemy 长时间运行的脚本 : User was holding a relation lock for too long

sql - 获取postgresql中hstore数据的每行键数

python - 如何 INSERT ... ON CONFLICT DO UPDATE 自动更新 TIMESTAMP?

java - 从 jar 文件内启动 postgres docker 失败

ruby-on-rails - ActiveRecord 和 Postgresql 的枚举类型

postgresql - 如何在postgresql8.2中将base64字符串转换为bytea