forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
288 lines
46 KiB
HTML
288 lines
46 KiB
HTML
<a name="EN-US_TOPIC_0000001234200629"></a><a name="EN-US_TOPIC_0000001234200629"></a>
|
|
|
|
<h1 class="topictitle1">Data Manipulation Language (DML)</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_p1396172372712">This section describes the migration syntax of MySQL DML. The migration syntax determines how the keywords and features are migrated.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_p13441139162713">For details, see the following topics:</p>
|
|
<ul id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_ul987568142818"><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li787588162817"><a href="#EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section1449751153020">INSERT</a></li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li17678102284"><a href="#EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section68760571318">UPDATE</a></li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li11138141314288"><a href="#EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section234585863114">REPLACE</a></li></ul>
|
|
<div class="section" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section1449751153020"><a name="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section1449751153020"></a><a name="en-us_topic_0238518451_en-us_topic_0237362190_section1449751153020"></a><h4 class="sectiontitle">INSERT</h4><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_p16270134133514">In MySQL, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1610211131011">INSERT</strong> allows the following keywords: <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b181028120107">HIGH_PRIORITY</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b31022015106">LOW_PRIORITY</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b3102171151012">PARTITION</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b3102215107">DELAYED</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b710212110107">IGNORE</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1710212119102">VALUES</strong>, and <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b161029141011">ON DUPLICATE KEY UPDATE</strong>. <span id="EN-US_TOPIC_0000001234200629__text10892754124514">GaussDB(DWS)</span> does not support these keywords, and DSC will convert them.</p>
|
|
<ol id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_ol862862143412"><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li162822113414"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b3168911143417">HIGH_PRIORITY</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164476_p118789701911">MySQL uses HIGH_PRIORITY will override the effect of the LOW_PRIORITY option.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164476_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b109538233105">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164476_screen593131013157"># HIGH_PRIORITY
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 VALUES(100, 12.3, 'cheap', '2018-11-11');
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 VALUES(DEFAULT, 128.23, 'nice', '2018-10-11');
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 VALUES(DEFAULT, DEFAULT, 'nice', '2018-12-14');
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 VALUES(DEFAULT, DEFAULT, 'nice', DEFAULT);
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price) VALUES(DEFAULT, DEFAULT);
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price, tb2_note) VALUES(DEFAULT, DEFAULT, DEFAULT);
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price , tb2_note) VALUES(DEFAULT, DEFAULT, DEFAULT);
|
|
INSERT HIGH_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price, tb2_note, tb2_date) VALUES(DEFAULT, DEFAULT, DEFAULT, DEFAULT);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164476_p11375155861510"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b489513475109">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164476_screen1739017129175">-- HIGH_PRIORITY
|
|
INSERT INTO "public"."exmp_tb2" VALUES (100,12.3,'cheap','2018-11-11');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,128.23,'nice','2018-10-11');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice','2018-12-14');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (DEFAULT,DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (DEFAULT,DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note","tb2_date") VALUES (DEFAULT,DEFAULT,DEFAULT,DEFAULT);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li186282021343"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b12171111143415">LOW_PRIORITY</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164694_p435710129191">When the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b167690190113">LOW_PRIORITY</strong> modifier is used, execution of <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b277021915112">INSERT</strong> is delayed.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164694_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b898362961115">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164694_screen1281419587177"># LOW_PRIORITY
|
|
INSERT LOW_PRIORITY INTO exmp_tb2 VALUES( DEFAULT, '128.23', 'nice', '2018-10-11');
|
|
INSERT LOW_PRIORITY INTO exmp_tb2 VALUES(DEFAULT, DEFAULT, 'nice', '2018-12-14' );
|
|
INSERT LOW_PRIORITY INTO exmp_tb2 VALUES(DEFAULT, DEFAULT, 'nice', DEFAULT);
|
|
INSERT LOW_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price) VALUES(DEFAULT, DEFAULT);
|
|
INSERT LOW_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price, tb2_note) VALUES(DEFAULT, DEFAULT, DEFAULT);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164694_p1624931841819"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b62748494114">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164694_screen1043813325188">-- LOW_PRIORITY
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,'128.23','nice','2018-10-11');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice','2018-12-14');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (DEFAULT,DEFAULT,DEFAULT);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li186282026343"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b17173011163412">PRATITION</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164560_p8060118">When inserting into a partitioned table, you can control which partitions and subpartitions accept new rows.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164560_p3632721121918"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1884619374120">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164560_screen127044111221">INSERT INTO employees PARTITION(p3) VALUES (19, 'Frank1', 'Williams', 1, 2);
|
|
INSERT INTO employees PARTITION(p0) VALUES (4, 'Frank1', 'Williams', 1, 2);
|
|
INSERT INTO employees PARTITION(p1) VALUES (9, 'Frank1', 'Williams', 1, 2);
|
|
INSERT INTO employees PARTITION(p2) VALUES (10, 'Frank1', 'Williams', 1, 2);
|
|
INSERT INTO employees PARTITION(p2) VALUES (11, 'Frank1', 'Williams', 1, 2);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164560_p1272512892216"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b92611596128">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164560_screen7637142002213">INSERT INTO "public"."employees" VALUES (19,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (4,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (9,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (10,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (11,'Frank1','Williams',1,2);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li46287253415"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b517441119348">DELAYED</strong><div class="notice" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164590_note5949526295"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164590_p1497119263920">In MySQL 5.7, the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b15416523141617">DELAYED</strong> keyword is recognized but ignored by the server.</p>
|
|
</div></div>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164590_p13257114517221"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1373203118167">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164590_screen15953195662215"># DELAYED
|
|
INSERT DELAYED INTO exmp_tb2 VALUES(99, 15.68, 'good', '2018-11-12');
|
|
INSERT DELAYED INTO exmp_tb2 VALUES(80, 12.3, 'cheap', '2018-11-11');
|
|
INSERT DELAYED INTO exmp_tb2 VALUES(DEFAULT, 128.23, 'nice', '2018-10-11');
|
|
INSERT DELAYED INTO exmp_tb2 VALUES(DEFAULT, DEFAULT, 'nice', '2018-12-14');
|
|
INSERT DELAYED INTO exmp_tb2 VALUES(DEFAULT, DEFAULT, 'nice', DEFAULT);
|
|
INSERT DELAYED INTO exmp_tb2 (tb2_id, tb2_price) VALUES(DEFAULT, DEFAULT);
|
|
INSERT DELAYED INTO exmp_tb2 (tb2_id, tb2_price, tb2_note) VALUES(DEFAULT, DEFAULT, DEFAULT);
|
|
INSERT DELAYED INTO exmp_tb2 (tb2_id, tb2_price, tb2_note, tb2_date) VALUES(DEFAULT, DEFAULT, DEFAULT, DEFAULT);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164590_p1937164612512"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b135665621619">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164590_screen205013568253">-- DELAYED
|
|
INSERT INTO "public"."exmp_tb2" VALUES (99,15.68,'good','2018-11-12');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (80,12.3,'cheap','2018-11-11');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,128.23,'nice','2018-10-11');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice','2018-12-14');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (DEFAULT,DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note","tb2_date") VALUES (DEFAULT,DEFAULT,DEFAULT,DEFAULT);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li106284283413"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b017514119346">IGNORE</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164397_p8060118">When the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b17885718181710">IGNORE</strong> modifier is used, errors that occur during <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b118851187171">INSERT</strong> execution are ignored.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164397_p983394010296"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b78861018141714">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164397_screen123475526298"># New data will be ignored if there is duplicate in the table.
|
|
INSERT IGNORE INTO exmp_tb2 VALUES(189, '189.23','nice','2017-11-12');
|
|
INSERT IGNORE INTO exmp_tb2 VALUES(130,'189.23','nice','2017-11-12');
|
|
INSERT IGNORE INTO exmp_tb2 VALUES(120,15.68,'good','2018-11-12');
|
|
INSERT IGNORE INTO exmp_tb2 VALUES(DEFAULT,128.23,'nice','2018-10-11');
|
|
INSERT IGNORE INTO exmp_tb2 VALUES(DEFAULT,DEFAULT,'nice','2018-12-14');
|
|
INSERT IGNORE INTO exmp_tb2 VALUES(DEFAULT,DEFAULT,'nice',DEFAULT);test
|
|
INSERT IGNORE INTO exmp_tb2 (tb2_id,tb2_price) VALUES(DEFAULT,DEFAULT);
|
|
INSERT IGNORE INTO exmp_tb2 (tb2_id,tb2_price,tb2_note) VALUES(DEFAULT,DEFAULT,DEFAULT);
|
|
INSERT IGNORE INTO exmp_tb2 (tb2_id,tb2_price,tb2_note,tb2_date) VALUES(DEFAULT,DEFAULT,DEFAULT,DEFAULT);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164397_p29091657112913"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b875218425176">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164397_screen206763820304">-- New data will be ignored if there is duplicate in the table.
|
|
INSERT INTO "public"."exmp_tb2" VALUES (101,'189.23','nice','2017-11-12');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (130,'189.23','nice','2017-11-12');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (120,15.68,'good','2018-11-12');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,128.23,'nice','2018-10-11');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice','2018-12-14');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (DEFAULT,DEFAULT,'nice',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (DEFAULT,DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note","tb2_date") VALUES (DEFAULT,DEFAULT,DEFAULT,DEFAULT);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li362813214345"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1839881099">VALUES</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164662_p8060118">INSERT statements use the VALUES syntax can insert multiple lines, separated by commas.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164662_p13900125273210"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b129073061817">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164662_screen1018565173318">INSERT INTO exmp_tb1 (tb1_name,tb1_sex,tb1_address,tb1_number) VALUES('David','male','NewYork','01015827875'),('Rachel','female','NewYork','01015827749'),('Monica','female','NewYork','010158996743');</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164662_p430961011330"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b6686152041810">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164662_screen144111513342">INSERT INTO "public"."exmp_tb1" ("tb1_name","tb1_sex","tb1_address","tb1_number") VALUES ('David','male','NewYork','01015827875');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_name","tb1_sex","tb1_address","tb1_number") VALUES ('Rachel','female','NewYork','01015827749');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_name","tb1_sex","tb1_address","tb1_number") VALUES ('Monica','female','NewYork','010158996743');</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li186284223417"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b4176101117349">ON DUPLICATE KEY UPDATE</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164705_p0737100151618">INSERT uses the ON DUPLICATE KEY UPDATE clause to update existing rows.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164705_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b84291146181814">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_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_0000001234200629__en-us_topic_0237712566_b64591856191817">UPDATE</strong> will work. Otherwise, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b15459195615188">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_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164705_p10860850329"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b101266021911">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_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_0000001234200629__en-us_topic_0237712566_b243215104198">UPDATE</strong> will work. Otherwise, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b34321110121920">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>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li116281521345"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b11177911163410">SET</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164674_p8060118">MySQL INSERT...SET statement inserts rows based on explicitly specified values.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164674_p1331019407411"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1292611918196">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164674_screen432820548410"># INSERT INTO SET (Data records can be inserted specially. One record can be inserted at a time, and batch insertion is not supported.)
|
|
INSERT INTO exmp_tb2 SET tb2_price=56.1,tb2_note='unbelievable',tb2_date='2018-11-13';
|
|
INSERT INTO exmp_tb2 SET tb2_price=99.9,tb2_note='perfect',tb2_date='2018-10-13';
|
|
INSERT INTO exmp_tb2 SET tb2_id=9,tb2_price=99.9,tb2_note='perfect',tb2_date='2018-10-13';</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164674_p189916016719"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1459863710197">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164674_screen921671516716">-- INSERT INTO SET (Data records can be inserted specially. One record can be inserted at a time, and batch insertion is not supported.)
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_price","tb2_note","tb2_date") VALUES (56.1,'unbelievable','2018-11-13');
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_price","tb2_note","tb2_date") VALUES (99.9,'perfect','2018-10-13');
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note","tb2_date") VALUES (9,99.9,'perfect','2018-10-13');</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section68760571318"><a name="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section68760571318"></a><a name="en-us_topic_0238518451_en-us_topic_0237362190_section68760571318"></a><h4 class="sectiontitle">UPDATE</h4><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_p8305181913372">In MySQL, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b01611554101918">UPDATE</strong> allows the following keywords: <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b11612543196">LOW_PRIORITY</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b116165411915">ORDER BY</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b7161145481916">LIMIT</strong>, and <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b11611654121919">IGNORE</strong>. <span id="EN-US_TOPIC_0000001234200629__text7771165584913">GaussDB(DWS)</span> does not support these keywords, and DSC will convert them.</p>
|
|
<ol id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_ol491810251347"><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li149181925103414"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b182423296343">LOW_PRIORITY</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164767_p1186115542211">With the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b6973377204">LOW_PRIORITY</strong> modifier, execution of <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b189731276203">UPDATE</strong> is delayed.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164767_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1823841562019">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164767_screen18330185120183"># LOW_PRIORITY
|
|
UPDATE LOW_PRIORITY employees SET department_id=2;</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164767_p53315611815"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b11461832172014">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164767_screen42227714193">-- LOW_PRIORITY
|
|
UPDATE "public"."employees" SET "department_id" = 2;</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li189181425143412"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b16244629193410">ORDER_BY</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164431_p19579230122414">In MySQL, if an <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1447427162117">UPDATE</strong> statement includes an <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b5474197102120">ORDER BY</strong> clause, the rows will be updated in the order specified by the clause.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164431_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b357914536216">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164431_screen1251619362013"># ORDER BY
|
|
UPDATE employees SET department_id=department_id+1 ORDER BY id;</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164431_p8785143932018"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b10618131802219">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164431_screen528325392010">-- ORDER BY
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1;</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li89182025193418"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b52459291346">LIMIT</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164556_p1517232891914">UPDATE LIMIT syntax can be used to limit the scope. A clause is a limit on row matching. As long as the rows that satisfy the clause are found, the statements will stop, regardless of whether they have actually changed.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164556_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b8779113811225">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164556_screen138616389229"># LIMIT
|
|
UPDATE employees SET department_id=department_id+1 LIMIT 3 ;
|
|
UPDATE employees SET department_id=department_id+1 LIMIT 3 , 10 ;
|
|
|
|
# LIMIT + OFFSET
|
|
UPDATE employees SET department_id=department_id+1 LIMIT 3 OFFSET 2;
|
|
|
|
# LIMIT + ORDER BY
|
|
UPDATE employees SET department_id=department_id+1 ORDER BY fname LIMIT 3 ;
|
|
|
|
# LIMIT + WHERE + ORDER BY
|
|
UPDATE employees SET department_id=department_id+1 WHERE id<5 ORDER BY fname LIMIT 3 ;
|
|
|
|
# LIMIT + WHERE + ORDER BY + OFFSET
|
|
UPDATE employees SET department_id=department_id+1 WHERE id<5 ORDER BY fname LIMIT 3 OFFSET 2 ;</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164556_p19586832152712"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b173841953162213">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164556_screen196344592911">-- LIMIT
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1;
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1;
|
|
|
|
-- LIMIT + OFFSET
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1;
|
|
|
|
-- LIMIT + ORDER BY
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1;
|
|
|
|
-- LIMIT + WHERE + ORDER BY
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1 WHERE id<5;
|
|
|
|
-- LIMIT + WHERE + ORDER BY + OFFSET
|
|
UPDATE "public"."employees" SET "department_id" = department_id+1 WHERE id<5;</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li129181825103416"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b824610298347">IGNORE</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164649_p54501782310">With the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b395313129239">IGNORE</strong> modifier, the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b12953181282315">UPDATE</strong> statement does not abort even if errors occur during execution.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164649_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b67174253230">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164649_screen155688533483"># IGNORE
|
|
UPDATE IGNORE employees SET department_id=3;</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164649_p12420113164917"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1345414445231">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164649_screen1445841344913">-- IGNORE
|
|
UPDATE "public"."employees" SET "department_id" = 3;</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section234585863114"><a name="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_section234585863114"></a><a name="en-us_topic_0238518451_en-us_topic_0237362190_section234585863114"></a><h4 class="sectiontitle">REPLACE</h4><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164395_p8060118">In MySQL, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1912191102410">REPLACE</strong> allows the following keywords: <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b121231116248">LOW_PRIORITY</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b13129117240">PARTITION</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b111261112411">DELAYED</strong>, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1512211132417">VALUES</strong>, and <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b12129114246">SET</strong>. The following examples are temporary migration solutions only.</p>
|
|
<div class="note" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164395_note231022161112"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164395_p203101928111"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1678272714241">REPLACE</strong> works exactly like <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b137835271242">INSERT</strong>, except that if an old row in the table has the same value as a new row for a primary key or unique index, the old row is deleted before the new row is inserted.</p>
|
|
</div></div>
|
|
<ol id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_ol8205104112348"><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li5205184183414"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b12203114217341">LOW_PRIORITY</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164610_p32131018312">MySQL REPLACE supports the use of LOW_PRIORITY, which is converted by the Migration tool.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164610_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b3487204142415">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164610_screen4506201965413"># LOW_PRIORITY
|
|
Replace LOW_PRIORITY INTO exmp_tb2 VALUES(1, '128.23', 'nice', '2018-10-11 19:00:00');
|
|
Replace LOW_PRIORITY INTO exmp_tb2 VALUES(2, DEFAULT, 'nice', '2018-12-14 19:00:00' );
|
|
Replace LOW_PRIORITY INTO exmp_tb2 VALUES(3, DEFAULT, 'nice', DEFAULT);
|
|
Replace LOW_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price) VALUES(5, DEFAULT);
|
|
Replace LOW_PRIORITY INTO exmp_tb2 (tb2_id, tb2_price, tb2_note) VALUES(4, DEFAULT, DEFAULT);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164610_p16908173019578"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b118973588248">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164610_screen16927144210574">-- LOW_PRIORITY
|
|
INSERT INTO "public"."exmp_tb2" VALUES (1,'128.23','nice','2018-10-11 19:00:00');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (2,DEFAULT,'nice','2018-12-14 19:00:00');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (3,DEFAULT,'nice',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (5,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (4,DEFAULT,DEFAULT);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li2020511412344"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b920664223414">PARTITION</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164784_p16920195411291">MySQL REPLACE supports explicit partitioning selection using the PARTITION keyword and a comma-separated name list for partitions, subpartitions, or both.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164784_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1490517151258">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164784_screen583134913110">replace INTO employees PARTITION(p3) VALUES (19, 'Frank1', 'Williams', 1, 2);
|
|
replace INTO employees PARTITION(p0) VALUES (4, 'Frank1', 'Williams', 1, 2);
|
|
replace INTO employees PARTITION(p1) VALUES (9, 'Frank1', 'Williams', 1, 2);
|
|
replace INTO employees PARTITION(p2) VALUES (10, 'Frank1', 'Williams', 1, 2);
|
|
replace INTO employees PARTITION(p2) VALUES (11, 'Frank1', 'Williams', 1, 2);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164784_p169797531015"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1011183413253">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164784_screen116246624">INSERT INTO "public"."employees" VALUES (19,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (4,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (9,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (10,'Frank1','Williams',1,2);
|
|
INSERT INTO "public"."employees" VALUES (11,'Frank1','Williams',1,2);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li142059418348"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b13207114215347">DELAYED</strong><div class="warning" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164482_note29110268416"><span class="warningtitle"><img src="public_sys-resources/warning_3.0-en-us.png"> </span><div class="warningbody"><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164482_p391112268419"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b15417517269">DELAYED</strong> <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b45416517264">INSERT</strong> and <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1254155263">REPLACE</strong> operations were deprecated in MySQL 5.6. In MySQL 5.7, <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b20542542616">DELAYED</strong> was not supported. The server recognizes but ignores the <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b16548552611">DELAYED</strong> keyword, handles <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b2551852260">REPLACE</strong> as a non-delayed one, and generates an <strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b15551255269">ER_WARN_LEGACY_SYNTAX_CONVERTED</strong> warning. (<strong id="EN-US_TOPIC_0000001234200629__b32464186324">REPLACE DELAYED</strong> is no longer supported, and the statement is converted to <strong id="EN-US_TOPIC_0000001234200629__b10973172313218">REPLACE</strong>.) The keyword <strong id="EN-US_TOPIC_0000001234200629__b17214210320">DELAYED</strong> will be deleted in later versions.</p>
|
|
</div></div>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164482_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1058193016271">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164482_screen20978453165814">#DELAYED INSERT DELAYED works only with MyISAM, MEMORY, ARCHIVE, and BLACKHOLE tables.
|
|
#If you execute INSERT DELAYED with another storage engine,
|
|
#you will get an error like this: ERROR 1616 (HY000): DELAYED option not supported
|
|
Replace DELAYED INTO exmp_tb2 VALUES(10, 128.23, 'nice', '2018-10-11 19:00:00');
|
|
Replace DELAYED INTO exmp_tb2 VALUES(6, DEFAULT, 'nice', '2018-12-14 19:00:00');
|
|
Replace DELAYED INTO exmp_tb2 VALUES(7, 20, 'nice', DEFAULT);
|
|
Replace DELAYED INTO exmp_tb2 (tb2_id, tb2_price) VALUES(11, DEFAULT);
|
|
Replace DELAYED INTO exmp_tb2 (tb2_id, tb2_price, tb2_note) VALUES(12, DEFAULT, DEFAULT);
|
|
Replace DELAYED INTO exmp_tb2 (tb2_id, tb2_price, tb2_note, tb2_date) VALUES(13, DEFAULT, DEFAULT, DEFAULT);</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164482_p18723678596"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b94644596279">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164482_screen1474124285915">--DELAYED INSERT DELAYED works only with MyISAM, MEMORY, ARCHIVE, and BLACKHOLE tables.
|
|
--If you execute INSERT DELAYED with another storage engine,
|
|
--you will get an error like this: ERROR 1616 (HY000): DELAYED option not supported.
|
|
INSERT INTO "public"."exmp_tb2" VALUES (10,128.23,'nice','2018-10-11 19:00:00');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (6,DEFAULT,'nice','2018-12-14 19:00:00');
|
|
INSERT INTO "public"."exmp_tb2" VALUES (7,20,'nice',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price") VALUES (11,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note") VALUES (12,DEFAULT,DEFAULT);
|
|
INSERT INTO "public"."exmp_tb2" ("tb2_id","tb2_price","tb2_note","tb2_date") VALUES (13,DEFAULT,DEFAULT,DEFAULT);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li14205154113341"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b820712429341">VALUES</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164526_p583023710322">MySQL REPLACE supports a statement to insert or delete multiple values, separated by commas.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164526_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b1257102092819">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164526_screen1378217271865"># If data is available, replacement will be performed. Otherwise, insertion will be performed.
|
|
Replace INTO exmp_tb1 (tb1_id,tb1_name,tb1_sex,tb1_address,tb1_number) VALUES(17,'David','male','NewYork11','01015827875'),(18,'Rachel','female','NewYork22','01015827749'),(20,'Monica','female','NewYork','010158996743');
|
|
Replace INTO exmp_tb1 (tb1_id,tb1_name,tb1_sex,tb1_address,tb1_number) VALUES(17,'David1','male','NewYork11','01015827875'),(21,'Rachel','female','NewYork22','01015827749'),(22,'Monica','female','NewYork','010158996743');
|
|
Replace INTO exmp_tb1 (tb1_id,tb1_name,tb1_sex,tb1_address,tb1_number,tb1_date) VALUES(17,'David2',DEFAULT,'NewYork11','01015827875',DEFAULT),(18,'Rachel','female',DEFAULT,'01015827749','2018-12-14 10:44:20'),(DEFAULT,'Monica','female',DEFAULT,DEFAULT,'2018-12-14 10:44:20');
|
|
Replace INTO exmp_tb1 VALUES(DEFAULT,'David',DEFAULT,'NewYork11','01015827875',DEFAULT),(18,'Rachel','female',DEFAULT,'01015827749','2018-12-14 10:44:20'),(DEFAULT,'Monica','female',DEFAULT,DEFAULT,'2018-12-14 10:44:20');</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164526_p5839501968"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b162347210294">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164526_screen17365131977">-- If data is available, replacement will be performed. Otherwise, insertion will be performed.
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number") VALUES (17,'David','male','NewYork11','01015827875');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number") VALUES (18,'Rachel','female','NewYork22','01015827749');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number") VALUES (20,'Monica','female','NewYork','010158996743');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number") VALUES (17,'David1','male','NewYork11','01015827875');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number") VALUES (21,'Rachel','female','NewYork22','01015827749');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number") VALUES (22,'Monica','female','NewYork','010158996743');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number","tb1_date") VALUES (17,'David2',DEFAULT,'NewYork11','01015827875',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number","tb1_date") VALUES (18,'Rachel','female',DEFAULT,'01015827749','2018-12-14 10:44:20');
|
|
INSERT INTO "public"."exmp_tb1" ("tb1_id","tb1_name","tb1_sex","tb1_address","tb1_number","tb1_date") VALUES (DEFAULT,'Monica','female',DEFAULT,DEFAULT,'2018-12-14 10:44:20');
|
|
INSERT INTO "public"."exmp_tb1" VALUES (DEFAULT,'David',DEFAULT,'NewYork11','01015827875',DEFAULT);
|
|
INSERT INTO "public"."exmp_tb1" VALUES (18,'Rachel','female',DEFAULT,'01015827749','2018-12-14 10:44:20');
|
|
INSERT INTO "public"."exmp_tb1" VALUES (DEFAULT,'Monica','female',DEFAULT,DEFAULT,'2018-12-14 10:44:20');</pre>
|
|
</li><li id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_li11205641193417"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_b142087424340">SET</strong><p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164445_p1772115533343">MySQL REPLACE supports the use of SET settings, which the Migration tool will convert.</p>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164445_p8060118"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b182801232162911">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164445_screen133614117112">replace INTO `runoob_datatype_test` VALUES (100, 100, 100, 0, 1);
|
|
replace INTO `runoob_datatype_test` VALUES (100.23, 100.25, 100.26, 0.12,1.5);
|
|
replace INTO `runoob_datatype_test` (dataType_numeric,dataType_numeric1) VALUES (100.23, 100.25);
|
|
replace INTO `runoob_datatype_test` (dataType_numeric,dataType_numeric1,dataType_numeric2) VALUES (100.23, 100.25, 2.34);
|
|
replace into runoob_datatype_test set dataType_numeric=23.1, dataType_numeric4 = 25.12 ;</pre>
|
|
<p id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164445_p1655610571120"><strong id="EN-US_TOPIC_0000001234200629__en-us_topic_0237712566_b14952151142916">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001234200629__en-us_topic_0238518451_en-us_topic_0237362190_en-us_topic_0214164445_screen531101513116">INSERT INTO "public"."runoob_datatype_test" VALUES (100,100,100,0,1);
|
|
INSERT INTO "public"."runoob_datatype_test" VALUES (100.23,100.25,100.26,0.12,1.5);
|
|
INSERT INTO "public"."runoob_datatype_test" ("datatype_numeric","datatype_numeric1") VALUES (100.23,100.25);
|
|
INSERT INTO "public"."runoob_datatype_test" ("datatype_numeric","datatype_numeric1","datatype_numeric2") VALUES (100.23,100.25,2.34);
|
|
INSERT INTO "public"."runoob_datatype_test" ("datatype_numeric","datatype_numeric4") VALUES (23.1,25.12);</pre>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_sct_0013.html">MySQL Syntax Migration</a></div>
|
|
</div>
|
|
</div>
|
|
|