UPDATE LIMIT语法可以用来限制的范围。一个子句是一个行匹配的限制。只要发现满足该子句的行, 语句就会停下来 ,不管它们是否真的发生了变化。
#单独测试 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 ;
--单独测试 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;