更新时间:2024-06-29 GMT+08:00
分享

LIMIT

UPDATE LIMIT语法可以用来限制的范围。一个子句是一个行匹配的限制。只要发现满足该子句的行, 语句就会停下来 ,不管它们是否真的发生了变化。

输入示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#单独测试 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 ;

输出示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
--单独测试 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;
分享:

    相关文档

    相关产品