我正在使用 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/