<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: PostgreSQL 9.5: Insert IF not Exists, Update IF Exists (Insert ON CONFLICT option)	</title>
	<atom:link href="https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 10 Jan 2019 06:35:49 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>
		By: Bea		</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-6841</link>

		<dc:creator><![CDATA[Bea]]></dc:creator>
		<pubDate>Thu, 10 Jan 2019 06:35:49 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3449#comment-6841</guid>

					<description><![CDATA[Thanks!]]></description>
			<content:encoded><![CDATA[<p>Thanks!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Muhammad Waqas		</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-6840</link>

		<dc:creator><![CDATA[Muhammad Waqas]]></dc:creator>
		<pubDate>Wed, 09 Jan 2019 15:55:22 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3449#comment-6840</guid>

					<description><![CDATA[@OmarBenSalem
In my case it&#039;s working all fine. I &#039;m using 2 tables, &quot;customer_stage&quot; as source and &quot;customer&quot; as target. &quot;customer_stage&quot; table has 6 rows and &quot;customer&quot; table is empty initially. After executing following statement all the 6 records from &quot;customer_stage&quot; are inserted to &quot;customer&quot; table:

INSERT INTO customer (cust_id, name, address) 
SELECT cust_id, name, address
FROM   customer_stage
ON     CONFLICT (cust_id) DO UPDATE
SET    address = excluded.address;

As your comment is too much old and I&#039;ve tried it today, there are chances that ON CONFLICT clause might have got some improvements.]]></description>
			<content:encoded><![CDATA[<p>@OmarBenSalem<br />
In my case it&#8217;s working all fine. I &#8216;m using 2 tables, &#8220;customer_stage&#8221; as source and &#8220;customer&#8221; as target. &#8220;customer_stage&#8221; table has 6 rows and &#8220;customer&#8221; table is empty initially. After executing following statement all the 6 records from &#8220;customer_stage&#8221; are inserted to &#8220;customer&#8221; table:</p>
<p>INSERT INTO customer (cust_id, name, address)<br />
SELECT cust_id, name, address<br />
FROM   customer_stage<br />
ON     CONFLICT (cust_id) DO UPDATE<br />
SET    address = excluded.address;</p>
<p>As your comment is too much old and I&#8217;ve tried it today, there are chances that ON CONFLICT clause might have got some improvements.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Muhammad Waqas		</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-6839</link>

		<dc:creator><![CDATA[Muhammad Waqas]]></dc:creator>
		<pubDate>Wed, 09 Jan 2019 15:53:23 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3449#comment-6839</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-5941&quot;&gt;OmarBenSalem&lt;/a&gt;.

In my case it&#039;s working all fine. I &#039;m using 2 tables, &quot;customer_stage&quot; as source and &quot;customer&quot; as target. &quot;customer_stage&quot; table has 6 rows and &quot;customer&quot; table is empty initially. After executing following statement all the 6 records from &quot;customer_stage&quot; are inserted to &quot;customer&quot; table:

INSERT INTO customer (cust_id, name, address) 
SELECT cust_id, name, address
FROM   customer_stage
ON     CONFLICT (cust_id) DO UPDATE
SET    address = excluded.address;

As your comment is too much old and I&#039;ve tried it today, there are chances that ON CONFLICT clause might have got some improvements.]]></description>
			<content:encoded><![CDATA[<p>In my case it&#8217;s working all fine. I &#8216;m using 2 tables, &#8220;customer_stage&#8221; as source and &#8220;customer&#8221; as target. &#8220;customer_stage&#8221; table has 6 rows and &#8220;customer&#8221; table is empty initially. After executing following statement all the 6 records from &#8220;customer_stage&#8221; are inserted to &#8220;customer&#8221; table:</p>
<p>INSERT INTO customer (cust_id, name, address)<br />
SELECT cust_id, name, address<br />
FROM   customer_stage<br />
ON     CONFLICT (cust_id) DO UPDATE<br />
SET    address = excluded.address;</p>
<p>As your comment is too much old and I&#8217;ve tried it today, there are chances that ON CONFLICT clause might have got some improvements.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martín Calvo		</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-6770</link>

		<dc:creator><![CDATA[Martín Calvo]]></dc:creator>
		<pubDate>Wed, 31 Oct 2018 17:25:57 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3449#comment-6770</guid>

					<description><![CDATA[Great tip... Thanks a lot!
Worked smoothly for me!]]></description>
			<content:encoded><![CDATA[<p>Great tip&#8230; Thanks a lot!<br />
Worked smoothly for me!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Anvesh Patel		</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-5948</link>

		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 23 Oct 2017 19:18:16 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3449#comment-5948</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-5941&quot;&gt;OmarBenSalem&lt;/a&gt;.

This trick is for existing data check, for the empty table you can execute simple INSERT and next time you can use this trick. I will also check one more time and will try to find other solution.]]></description>
			<content:encoded><![CDATA[<p>This trick is for existing data check, for the empty table you can execute simple INSERT and next time you can use this trick. I will also check one more time and will try to find other solution.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: OmarBenSalem		</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-9-5-insert-if-not-exists-update-if-exists-insert-on-conflict-do-update-do-nothing/#comment-5941</link>

		<dc:creator><![CDATA[OmarBenSalem]]></dc:creator>
		<pubDate>Mon, 23 Oct 2017 08:48:20 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3449#comment-5941</guid>

					<description><![CDATA[What I don&#039;t understand is when I use this:
BEGIN
   
       INSERT INTO alerts VALUES (alertname,desk,creationdate)
        
        ON CONFLICT (alertname)
      DO UPDATE SET desk = alerts.desk;

     END;

and that my table is empty, nothing happens, but when there are some values within the table, this does the trick.
The question is, how to do insert if there is no value in the table and update if there is a conflit
Thanks!]]></description>
			<content:encoded><![CDATA[<p>What I don&#8217;t understand is when I use this:<br />
BEGIN</p>
<p>       INSERT INTO alerts VALUES (alertname,desk,creationdate)</p>
<p>        ON CONFLICT (alertname)<br />
      DO UPDATE SET desk = alerts.desk;</p>
<p>     END;</p>
<p>and that my table is empty, nothing happens, but when there are some values within the table, this does the trick.<br />
The question is, how to do insert if there is no value in the table and update if there is a conflit<br />
Thanks!</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
