doc-exports/docs/dws/tool/dws_16_0196.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

44 lines
2.6 KiB
HTML

<a name="EN-US_TOPIC_0000001819416285"></a><a name="EN-US_TOPIC_0000001819416285"></a>
<h1 class="topictitle1">LIMIT</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_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_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_en-us_topic_0214164556_p8060118"><strong id="EN-US_TOPIC_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_en-us_topic_0214164556_b462343552212">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_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&lt;5 ORDER BY fname LIMIT 3 ;
# LIMIT + WHERE + ORDER BY + OFFSET
UPDATE employees SET department_id=department_id+1 WHERE id&lt;5 ORDER BY fname LIMIT 3 OFFSET 2 ;</pre>
<p id="EN-US_TOPIC_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_en-us_topic_0214164556_p19586832152712"><strong id="EN-US_TOPIC_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_en-us_topic_0214164556_b15245144242914">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819416285__en-us_topic_0000001657865374_en-us_topic_0000001438131241_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&lt;5;
-- LIMIT + WHERE + ORDER BY + OFFSET
UPDATE "public"."employees" SET "department_id" = department_id+1 WHERE id&lt;5;</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0193.html">UPDATE</a></div>
</div>
</div>