doc-exports/docs/dws/tool/dws_16_0191.html
Lu, Huayi 27019c2991 DWS TOOL 830.201 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:35:25 +00:00

24 lines
2.9 KiB
HTML

<a name="EN-US_TOPIC_0000001772536560"></a><a name="EN-US_TOPIC_0000001772536560"></a>
<h1 class="topictitle1">ON DUPLICATE KEY UPDATE</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_p0737100151618">INSERT uses the ON DUPLICATE KEY UPDATE clause to update existing rows.</p>
<p id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_p8060118"><strong id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_b161315107585">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_screen572419925815"># ON DUPLICATE KEY UPDATE (If new data will cause a duplicate value in the primary/unique key, <strong id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_b104917527131830">UPDATE</strong> will work. Otherwise, <strong id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_b178105499531830">INSERT</strong> will work.)
INSERT INTO exmp_tb2(tb2_id,tb2_price) VALUES(3,12.3) ON DUPLICATE KEY UPDATE tb2_price=12.3;
INSERT INTO exmp_tb2(tb2_id,tb2_price) VALUES(4,12.3) ON DUPLICATE KEY UPDATE tb2_price=12.3;
INSERT INTO exmp_tb2(tb2_id,tb2_price,tb2_note) VALUES(10,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE tb2_price=66.6;
INSERT INTO exmp_tb2(tb2_id,tb2_price,tb2_note,tb2_date) VALUES(11,DEFAULT,DEFAULT,DEFAULT) ON DUPLICATE KEY UPDATE tb2_price=66.6;</pre>
<p id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_p10860850329"><strong id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_b323418591124">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_en-us_topic_0214164705_screen1053112461424">-- ON DUPLICATE KEY UPDATE (If new data will cause a duplicate value in the primary/unique key, <strong id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_b179106597831830">UPDATE</strong> will work. Otherwise, <strong id="EN-US_TOPIC_0000001772536560__en-us_topic_0000001706104677_en-us_topic_0000001387252410_b136190395031830">INSERT</strong> will work.)
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (3,12.3);
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (4,12.3);
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (10,DEFAULT,DEFAULT);
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note","tb2_date") VALUES (11,DEFAULT,DEFAULT,DEFAULT);</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0184.html">INSERT</a></div>
</div>
</div>