2016-12-29 106 views
0

工作在我的Postgres 9.6環境中,當我嘗試執行「合併到」查詢時,它拋出我下面的錯誤:合併到不是隨着Postgres 9.6

ERROR: syntax error at or near "MERGE" 
LINE 1: MERGE INTO Stock USING Buy ON Stock.item_id = Buy.item_id W... 
     ^

現在看來似乎不支持MERGE查詢。但是,當我做谷歌,似乎MERGE從9.1版Postgres支持。

請告訴我這裏出了什麼問題。

編輯:以下是我在Postgres中找到MERGE支持的來源。

https://wiki.postgresql.org/wiki/MergeTestExamples

+1

從您發佈的鏈接:**這是從來沒有集成到PostgreSQL和要求顯著的工作是生產質量** –

+0

[在PostgreSQL中如何進行UPSERT(MERGE,INSERT ... ON DUPLICATE UPDATE)]可能的重複?](http://stackoverflow.com/questions/17267417/how-to-upsert-merge-insert-on -duplicate-update-in-postgresql) –

+0

唯一的身份驗證聲明的存在或語法的統一性來源是[**手冊**](https://www.postgresql.org/docs/current/static/index.html),不是一些隨機的谷歌搜索或維基頁面明確指出該功能沒有被集成到Postgres中 –

回答

0

MERGE又名INSERT ... ON CONFLICT DO NOTHING/UPDATEUPSERT只適用於postgres 9.5及更高版本:

Note: MERGE is often used interchangeably with the term UPSERT.

UPSERT functionality will be in the PostgreSQL 9.5 release -- see What's new in PostgreSQL 9.5 MERGE is not in 9.4.5 (the latest PostgreSQL release as of 2015-10-08)