From d47bd0c2ec667022da25456952efb6d39da76fa4 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 26 Mar 2026 14:29:27 +0800 Subject: [PATCH 1/3] [docs] Document ORDER BY and LIMIT support in UPDATE and DELETE statements Add documentation for the ORDER BY and LIMIT clauses in UPDATE and DELETE statements, as introduced by apache/doris#61681. Changes across dev (current) and 4.x versions, both English and Chinese: - Updated syntax blocks to include ORDER BY and LIMIT clauses - Added parameter descriptions for ORDER BY and LIMIT - Added usage examples with ORDER BY, LIMIT, and offset - Added 'since 4.1.0' version tags in 4.x versioned docs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../data-modification/DML/DELETE.md | 16 +++++++++++++++ .../data-modification/DML/UPDATE.md | 16 +++++++++++++++ .../data-modification/DML/DELETE.md | 16 +++++++++++++++ .../data-modification/DML/UPDATE.md | 16 +++++++++++++++ .../data-modification/DML/DELETE.md | 20 +++++++++++++++++++ .../data-modification/DML/UPDATE.md | 20 +++++++++++++++++++ .../data-modification/DML/DELETE.md | 20 +++++++++++++++++++ .../data-modification/DML/UPDATE.md | 20 +++++++++++++++++++ 8 files changed, 144 insertions(+) diff --git a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md index dc2c22396fbfb..2ca7455f5edf0 100644 --- a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -30,6 +30,8 @@ DELETE FROM table_name [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -46,6 +48,8 @@ DELETE FROM table_name + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal + table_alias: alias of table + USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. ++ ORDER BY column: Specifies the order in which rows are deleted. Used together with LIMIT to control which rows are affected. ++ LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. #### Note @@ -179,6 +183,18 @@ This feature is supported since the Apache Doris 1.2 version where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +6. Delete with ORDER BY and LIMIT — delete the first 3 rows ordered by k1 in ascending order + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 3; + ``` + +7. Delete with ORDER BY, LIMIT and offset — skip the first 10 rows and delete the next 5 rows ordered by k1 + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 10, 5; + ``` + ## Keywords DELETE diff --git a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md index a900a19db72d9..8f820a1f8c5ec 100644 --- a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -19,6 +19,8 @@ UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -32,6 +34,8 @@ UPDATE target_table [table_alias] + cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' + table_alias: alias of table + FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. ++ ORDER BY column: Specifies the order in which rows are updated. Used together with LIMIT to control which rows are affected. ++ LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. #### Note @@ -151,6 +155,18 @@ from discount_orders where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +5. Update with ORDER BY and LIMIT — update the v1 column to 0 for the first 3 rows with the largest v1 values where k1 > 0 + +```sql +UPDATE test SET v1 = 0 WHERE k1 > 0 ORDER BY v1 DESC LIMIT 3; +``` + +6. Update with ORDER BY, LIMIT and offset — skip the first 10 rows and update the next 5 rows ordered by k1 + +```sql +UPDATE test SET v1 = 100 ORDER BY k1 ASC LIMIT 10, 5; +``` + ## Keywords UPDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md index 9001d318d3757..b56aa28687cc1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -30,6 +30,8 @@ DELETE FROM table_name [table_alias] [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -46,6 +48,8 @@ DELETE FROM table_name [table_alias] + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): 指定执行删除数据的分区名,如果表不存在此分区,则报错 + table_alias: 表的别名 + USING additional_tables: 如果需要在 WHERE 语句中使用其他的表来帮助识别需要删除的行,则可以在 USING 中指定这些表或者查询。 ++ ORDER BY column: 指定删除行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被删除。 ++ LIMIT [offset,] count: 限制删除的行数。与 ORDER BY 一起使用时,排序后删除前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行删除。 #### Note @@ -174,6 +178,18 @@ DELETE FROM table_name [table_alias] where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +6. 使用 ORDER BY 和 LIMIT 删除数据——按照 k1 列升序排列,删除前 3 行 + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 3; + ``` + +7. 使用 ORDER BY、LIMIT 和 offset 删除数据——按照 k1 列升序排列,跳过前 10 行,删除接下来的 5 行 + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 10, 5; + ``` + ## 关键词 DELETE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md index cf6ec4496a5f4..71189234c3136 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -20,6 +20,8 @@ UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -33,6 +35,8 @@ UPDATE target_table [table_alias] + cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 + table_alias: 表的别名 + FROM additional_tables: 指定一个或多个表,用于选中更新的行,或者获取更新的值。注意,如需要在此列表中再次使用目标表,需要为其显式指定别名。 ++ ORDER BY column: 指定更新行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被更新。 ++ LIMIT [offset,] count: 限制更新的行数。与 ORDER BY 一起使用时,排序后更新前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行更新。 #### Note @@ -152,6 +156,18 @@ from discount_orders where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +5. 使用 ORDER BY 和 LIMIT 更新数据——按照 v1 列降序排列,更新满足 k1 > 0 条件的前 3 行的 v1 列为 0 + +```sql +UPDATE test SET v1 = 0 WHERE k1 > 0 ORDER BY v1 DESC LIMIT 3; +``` + +6. 使用 ORDER BY、LIMIT 和 offset 更新数据——按照 k1 列升序排列,跳过前 10 行,更新接下来的 5 行 + +```sql +UPDATE test SET v1 = 100 ORDER BY k1 ASC LIMIT 10, 5; +``` + ## 关键词 UPDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md index 9001d318d3757..7403e4793c446 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -30,6 +30,8 @@ DELETE FROM table_name [table_alias] [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -46,6 +48,12 @@ DELETE FROM table_name [table_alias] + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): 指定执行删除数据的分区名,如果表不存在此分区,则报错 + table_alias: 表的别名 + USING additional_tables: 如果需要在 WHERE 语句中使用其他的表来帮助识别需要删除的行,则可以在 USING 中指定这些表或者查询。 ++ ORDER BY column: 指定删除行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被删除。 ++ LIMIT [offset,] count: 限制删除的行数。与 ORDER BY 一起使用时,排序后删除前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行删除。 + +:::tip +DELETE 语句中的 ORDER BY 和 LIMIT 自 4.1.0 版本起支持。 +::: #### Note @@ -174,6 +182,18 @@ DELETE FROM table_name [table_alias] where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +6. 使用 ORDER BY 和 LIMIT 删除数据——按照 k1 列升序排列,删除前 3 行 + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 3; + ``` + +7. 使用 ORDER BY、LIMIT 和 offset 删除数据——按照 k1 列升序排列,跳过前 10 行,删除接下来的 5 行 + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 10, 5; + ``` + ## 关键词 DELETE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md index cf6ec4496a5f4..9d64b9d3b8249 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -20,6 +20,8 @@ UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -33,6 +35,12 @@ UPDATE target_table [table_alias] + cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 + table_alias: 表的别名 + FROM additional_tables: 指定一个或多个表,用于选中更新的行,或者获取更新的值。注意,如需要在此列表中再次使用目标表,需要为其显式指定别名。 ++ ORDER BY column: 指定更新行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被更新。 ++ LIMIT [offset,] count: 限制更新的行数。与 ORDER BY 一起使用时,排序后更新前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行更新。 + +:::tip +UPDATE 语句中的 ORDER BY 和 LIMIT 自 4.1.0 版本起支持。 +::: #### Note @@ -152,6 +160,18 @@ from discount_orders where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +5. 使用 ORDER BY 和 LIMIT 更新数据——按照 v1 列降序排列,更新满足 k1 > 0 条件的前 3 行的 v1 列为 0 + +```sql +UPDATE test SET v1 = 0 WHERE k1 > 0 ORDER BY v1 DESC LIMIT 3; +``` + +6. 使用 ORDER BY、LIMIT 和 offset 更新数据——按照 k1 列升序排列,跳过前 10 行,更新接下来的 5 行 + +```sql +UPDATE test SET v1 = 100 ORDER BY k1 ASC LIMIT 10, 5; +``` + ## 关键词 UPDATE diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md index dc2c22396fbfb..2c74cb24fbc89 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -30,6 +30,8 @@ DELETE FROM table_name [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -46,6 +48,12 @@ DELETE FROM table_name + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal + table_alias: alias of table + USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. ++ ORDER BY column: Specifies the order in which rows are deleted. Used together with LIMIT to control which rows are affected. ++ LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. + +:::tip +ORDER BY and LIMIT in DELETE statements are supported since version 4.1.0. +::: #### Note @@ -179,6 +187,18 @@ This feature is supported since the Apache Doris 1.2 version where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +6. Delete with ORDER BY and LIMIT — delete the first 3 rows ordered by k1 in ascending order + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 3; + ``` + +7. Delete with ORDER BY, LIMIT and offset — skip the first 10 rows and delete the next 5 rows ordered by k1 + + ```sql + DELETE FROM my_table ORDER BY k1 ASC LIMIT 10, 5; + ``` + ## Keywords DELETE diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md index a900a19db72d9..fdf1056c4963e 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -19,6 +19,8 @@ UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] WHERE condition + [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] + [LIMIT [offset,] count] ``` #### Required Parameters @@ -32,6 +34,12 @@ UPDATE target_table [table_alias] + cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' + table_alias: alias of table + FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. ++ ORDER BY column: Specifies the order in which rows are updated. Used together with LIMIT to control which rows are affected. ++ LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. + +:::tip +ORDER BY and LIMIT in UPDATE statements are supported since version 4.1.0. +::: #### Note @@ -151,6 +159,18 @@ from discount_orders where lineitem.o_orderkey = discount_orders.o_orderkey; ``` +5. Update with ORDER BY and LIMIT — update the v1 column to 0 for the first 3 rows with the largest v1 values where k1 > 0 + +```sql +UPDATE test SET v1 = 0 WHERE k1 > 0 ORDER BY v1 DESC LIMIT 3; +``` + +6. Update with ORDER BY, LIMIT and offset — skip the first 10 rows and update the next 5 rows ordered by k1 + +```sql +UPDATE test SET v1 = 100 ORDER BY k1 ASC LIMIT 10, 5; +``` + ## Keywords UPDATE From da21d76a6795152667575ce4526d8e54a7644e24 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 26 Mar 2026 14:37:40 +0800 Subject: [PATCH 2/3] [docs] Fix review: make WHERE optional in syntax, clarify ORDER BY description - Mark WHERE condition as optional [WHERE condition] in UPDATE and DELETE syntax blocks (consistent with grammar change in apache/doris#61681) - Change ORDER BY description from 'Used together with' to 'Typically used together with' to clarify it doesn't strictly require LIMIT Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../sql-manual/sql-statements/data-modification/DML/DELETE.md | 4 ++-- .../sql-manual/sql-statements/data-modification/DML/UPDATE.md | 4 ++-- .../sql-manual/sql-statements/data-modification/DML/DELETE.md | 2 +- .../sql-manual/sql-statements/data-modification/DML/UPDATE.md | 2 +- .../sql-manual/sql-statements/data-modification/DML/DELETE.md | 2 +- .../sql-manual/sql-statements/data-modification/DML/UPDATE.md | 2 +- .../sql-manual/sql-statements/data-modification/DML/DELETE.md | 4 ++-- .../sql-manual/sql-statements/data-modification/DML/UPDATE.md | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md index 2ca7455f5edf0..b333a7a10c3ca 100644 --- a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -29,7 +29,7 @@ Syntax 2: This syntax can only used on UNIQUE KEY model DELETE FROM table_name [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` @@ -48,7 +48,7 @@ DELETE FROM table_name + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal + table_alias: alias of table + USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. -+ ORDER BY column: Specifies the order in which rows are deleted. Used together with LIMIT to control which rows are affected. ++ ORDER BY column: Specifies the order in which rows are deleted. Typically used together with LIMIT to control which rows are affected. + LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. #### Note diff --git a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md index 8f820a1f8c5ec..b72d8a65ec702 100644 --- a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -18,7 +18,7 @@ The UPDATE operation currently only supports updating the Value column. The upda UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` @@ -34,7 +34,7 @@ UPDATE target_table [table_alias] + cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' + table_alias: alias of table + FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. -+ ORDER BY column: Specifies the order in which rows are updated. Used together with LIMIT to control which rows are affected. ++ ORDER BY column: Specifies the order in which rows are updated. Typically used together with LIMIT to control which rows are affected. + LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. #### Note diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md index b56aa28687cc1..f295c3f093c68 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -29,7 +29,7 @@ column_name op { value | value_list } [ AND column_name op { value | value_list DELETE FROM table_name [table_alias] [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md index 71189234c3136..57a59bd8ddcfa 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -19,7 +19,7 @@ UPDATE 操作目前只支持更新 Value 列,Key 列的更新可参考[使用 UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md index 7403e4793c446..c3d1e77117b88 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -29,7 +29,7 @@ column_name op { value | value_list } [ AND column_name op { value | value_list DELETE FROM table_name [table_alias] [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md index 9d64b9d3b8249..687549753f65a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -19,7 +19,7 @@ UPDATE 操作目前只支持更新 Value 列,Key 列的更新可参考[使用 UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md index 2c74cb24fbc89..abb26530d2771 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -29,7 +29,7 @@ Syntax 2: This syntax can only used on UNIQUE KEY model DELETE FROM table_name [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] [USING additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` @@ -48,7 +48,7 @@ DELETE FROM table_name + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal + table_alias: alias of table + USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. -+ ORDER BY column: Specifies the order in which rows are deleted. Used together with LIMIT to control which rows are affected. ++ ORDER BY column: Specifies the order in which rows are deleted. Typically used together with LIMIT to control which rows are affected. + LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. :::tip diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md index fdf1056c4963e..484285c26e790 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -18,7 +18,7 @@ The UPDATE operation currently only supports updating the Value column. The upda UPDATE target_table [table_alias] SET assignment_list [ FROM additional_tables] - WHERE condition + [WHERE condition] [ORDER BY column [ASC | DESC] [NULLS FIRST | NULLS LAST] [, ...]] [LIMIT [offset,] count] ``` @@ -34,7 +34,7 @@ UPDATE target_table [table_alias] + cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' + table_alias: alias of table + FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. -+ ORDER BY column: Specifies the order in which rows are updated. Used together with LIMIT to control which rows are affected. ++ ORDER BY column: Specifies the order in which rows are updated. Typically used together with LIMIT to control which rows are affected. + LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. :::tip From 6341a8529d47fb8549a5bfda034b6055eb70ceb6 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 26 Mar 2026 15:19:41 +0800 Subject: [PATCH 3/3] [docs] Fix review round 2: move WHERE to optional, add safety notes - Move WHERE condition from Required to Optional Parameters in all UPDATE and DELETE docs (consistent with syntax showing [WHERE condition]) - Add note clarifying WHERE is required for DELETE Syntax 1, optional for Syntax 2 - Add safety warning about omitting WHERE clause without LIMIT - Document that LIMIT without ORDER BY results in non-deterministic row selection Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../sql-statements/data-modification/DML/DELETE.md | 5 +++-- .../sql-statements/data-modification/DML/UPDATE.md | 6 ++++-- .../sql-statements/data-modification/DML/DELETE.md | 5 +++-- .../sql-statements/data-modification/DML/UPDATE.md | 6 ++++-- .../sql-statements/data-modification/DML/DELETE.md | 5 +++-- .../sql-statements/data-modification/DML/UPDATE.md | 6 ++++-- .../sql-statements/data-modification/DML/DELETE.md | 5 +++-- .../sql-statements/data-modification/DML/UPDATE.md | 6 ++++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md index b333a7a10c3ca..00e87b0a83c04 100644 --- a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -40,7 +40,6 @@ DELETE FROM table_name + column_name: column belong to table_name + op: Logical comparison operator, The optional types of op include: =, >, <, >=, <=, !=, in, not in + value | value_list: value or value list used for logial comparison -+ WHERE condition: Specifies a condition to use to select rows for removal #### Optional Parameters @@ -48,8 +47,9 @@ DELETE FROM table_name + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal + table_alias: alias of table + USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. ++ WHERE condition: Specifies a condition to use to select rows for removal. Required for Syntax 1. Optional for Syntax 2. + ORDER BY column: Specifies the order in which rows are deleted. Typically used together with LIMIT to control which rows are affected. -+ LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. ++ LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. If used without ORDER BY, the set of affected rows is non-deterministic. #### Note @@ -63,6 +63,7 @@ This feature is supported since the Apache Doris 1.2 version ::: 5. This statement may reduce query efficiency for a period of time after execution. The degree of impact depends on the number of delete conditions specified in the statement. The more conditions you specify, the greater the impact. +6. When neither `WHERE` nor `LIMIT` is specified in Syntax 2, all rows in the table will be deleted. Always verify the intended scope before omitting the `WHERE` clause. ## Example diff --git a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md index b72d8a65ec702..5d6634c17303f 100644 --- a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -27,20 +27,22 @@ UPDATE target_table [table_alias] + target_table: The target table of the data to be updated. Can be of the form 'db_name.table_name' + assignment_list: The target column to be updated, in the format 'col_name = value, col_name = value' -+ where condition: the condition that is expected to be updated, an expression that returns true or false can be #### Optional Parameters + cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' + table_alias: alias of table + FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. ++ WHERE condition: The condition that is expected to be updated, an expression that returns true or false. + ORDER BY column: Specifies the order in which rows are updated. Typically used together with LIMIT to control which rows are affected. -+ LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. ++ LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. If used without ORDER BY, the set of affected rows is non-deterministic. #### Note The current UPDATE statement only supports row updates on the UNIQUE KEY model. +When neither `WHERE` nor `LIMIT` is specified, all rows in the table will be updated. Always verify the intended scope before omitting the `WHERE` clause. + ## Example The `test` table is a unique model table, which contains four columns: k1, k2, v1, v2. Where k1, k2 are keys, v1, v2 are values, and the aggregation method is Replace. diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md index f295c3f093c68..aa3c6df6b2a45 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -40,7 +40,6 @@ DELETE FROM table_name [table_alias] + column_name: 属于 table_name 的列 + op: 逻辑比较操作符,可选类型包括:=, >, <, >=, <=, !=, in, not in + value | value_list: 做逻辑比较的值或值列表 -+ WHERE condition: 指定一个用于选择删除行的条件 #### Optional Parameters @@ -48,8 +47,9 @@ DELETE FROM table_name [table_alias] + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): 指定执行删除数据的分区名,如果表不存在此分区,则报错 + table_alias: 表的别名 + USING additional_tables: 如果需要在 WHERE 语句中使用其他的表来帮助识别需要删除的行,则可以在 USING 中指定这些表或者查询。 ++ WHERE condition: 指定一个用于选择删除行的条件。语法一中为必填项,语法二中为可选项。 + ORDER BY column: 指定删除行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被删除。 -+ LIMIT [offset,] count: 限制删除的行数。与 ORDER BY 一起使用时,排序后删除前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行删除。 ++ LIMIT [offset,] count: 限制删除的行数。与 ORDER BY 一起使用时,排序后删除前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行删除。如果不配合 ORDER BY 使用,受影响的行是不确定的。 #### Note @@ -58,6 +58,7 @@ DELETE FROM table_name [table_alias] 3. 语法一中,条件之间只能是“与”的关系。若希望达成“或”的关系,需要将条件分写在两个 DELETE 语句中。 4. 语法一中,如果为分区表,需要指定分区,如果不指定,doris 会从条件中推断出分区。两种情况下,doris 无法从条件中推断出分区:1) 条件中不包含分区列;2) 分区列的 op 为 not in。如果分区表不是 Unique 表,当分区表未指定分区,或者无法从条件中推断分区的时候,需要设置会话变量 delete_without_partition 为 true,此时 delete 会应用到所有分区。 5. 该语句可能会降低执行后一段时间内的查询效率。影响程度取决于语句中指定的删除条件的数量。指定的条件越多,影响越大。 +6. 在语法二中,如果既未指定 `WHERE` 也未指定 `LIMIT`,则会删除表中的所有行。请在省略 `WHERE` 子句前务必确认操作范围。 ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md index 57a59bd8ddcfa..9670d1a83156e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -28,20 +28,22 @@ UPDATE target_table [table_alias] + target_table: 待更新数据的目标表。可以是 'db_name.table_name' 形式 + assignment_list: 待更新的目标列,形如 'col_name = value, col_name = value' 格式 -+ WHERE condition: 期望更新的条件,一个返回 true 或者 false 的表达式即可 #### Optional Parameters + cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 + table_alias: 表的别名 + FROM additional_tables: 指定一个或多个表,用于选中更新的行,或者获取更新的值。注意,如需要在此列表中再次使用目标表,需要为其显式指定别名。 ++ WHERE condition: 期望更新的条件,一个返回 true 或者 false 的表达式即可。 + ORDER BY column: 指定更新行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被更新。 -+ LIMIT [offset,] count: 限制更新的行数。与 ORDER BY 一起使用时,排序后更新前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行更新。 ++ LIMIT [offset,] count: 限制更新的行数。与 ORDER BY 一起使用时,排序后更新前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行更新。如果不配合 ORDER BY 使用,受影响的行是不确定的。 #### Note 当前 UPDATE 语句仅支持在 UNIQUE KEY 模型上的行更新。 +如果既未指定 `WHERE` 也未指定 `LIMIT`,则会更新表中的所有行。请在省略 `WHERE` 子句前务必确认操作范围。 + ## 示例 `test` 表是一个 unique 模型的表,包含:k1, k2, v1, v2 四个列。其中 k1, k2 是 key,v1, v2 是 value,聚合方式是 Replace。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md index c3d1e77117b88..bc2c17c10020b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -40,7 +40,6 @@ DELETE FROM table_name [table_alias] + column_name: 属于 table_name 的列 + op: 逻辑比较操作符,可选类型包括:=, >, <, >=, <=, !=, in, not in + value | value_list: 做逻辑比较的值或值列表 -+ WHERE condition: 指定一个用于选择删除行的条件 #### Optional Parameters @@ -48,8 +47,9 @@ DELETE FROM table_name [table_alias] + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): 指定执行删除数据的分区名,如果表不存在此分区,则报错 + table_alias: 表的别名 + USING additional_tables: 如果需要在 WHERE 语句中使用其他的表来帮助识别需要删除的行,则可以在 USING 中指定这些表或者查询。 ++ WHERE condition: 指定一个用于选择删除行的条件。语法一中为必填项,语法二中为可选项。 + ORDER BY column: 指定删除行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被删除。 -+ LIMIT [offset,] count: 限制删除的行数。与 ORDER BY 一起使用时,排序后删除前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行删除。 ++ LIMIT [offset,] count: 限制删除的行数。与 ORDER BY 一起使用时,排序后删除前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行删除。如果不配合 ORDER BY 使用,受影响的行是不确定的。 :::tip DELETE 语句中的 ORDER BY 和 LIMIT 自 4.1.0 版本起支持。 @@ -62,6 +62,7 @@ DELETE 语句中的 ORDER BY 和 LIMIT 自 4.1.0 版本起支持。 3. 语法一中,条件之间只能是“与”的关系。若希望达成“或”的关系,需要将条件分写在两个 DELETE 语句中。 4. 语法一中,如果为分区表,需要指定分区,如果不指定,doris 会从条件中推断出分区。两种情况下,doris 无法从条件中推断出分区:1) 条件中不包含分区列;2) 分区列的 op 为 not in。如果分区表不是 Unique 表,当分区表未指定分区,或者无法从条件中推断分区的时候,需要设置会话变量 delete_without_partition 为 true,此时 delete 会应用到所有分区。 5. 该语句可能会降低执行后一段时间内的查询效率。影响程度取决于语句中指定的删除条件的数量。指定的条件越多,影响越大。 +6. 在语法二中,如果既未指定 `WHERE` 也未指定 `LIMIT`,则会删除表中的所有行。请在省略 `WHERE` 子句前务必确认操作范围。 ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md index 687549753f65a..2c4432c569787 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -28,15 +28,15 @@ UPDATE target_table [table_alias] + target_table: 待更新数据的目标表。可以是 'db_name.table_name' 形式 + assignment_list: 待更新的目标列,形如 'col_name = value, col_name = value' 格式 -+ WHERE condition: 期望更新的条件,一个返回 true 或者 false 的表达式即可 #### Optional Parameters + cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 + table_alias: 表的别名 + FROM additional_tables: 指定一个或多个表,用于选中更新的行,或者获取更新的值。注意,如需要在此列表中再次使用目标表,需要为其显式指定别名。 ++ WHERE condition: 期望更新的条件,一个返回 true 或者 false 的表达式即可。 + ORDER BY column: 指定更新行的排序方式。通常与 LIMIT 一起使用,以控制哪些行会被更新。 -+ LIMIT [offset,] count: 限制更新的行数。与 ORDER BY 一起使用时,排序后更新前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行更新。 ++ LIMIT [offset,] count: 限制更新的行数。与 ORDER BY 一起使用时,排序后更新前 `count` 行。如果指定了 `offset`,则跳过排序后的前 `offset` 行再进行更新。如果不配合 ORDER BY 使用,受影响的行是不确定的。 :::tip UPDATE 语句中的 ORDER BY 和 LIMIT 自 4.1.0 版本起支持。 @@ -46,6 +46,8 @@ UPDATE 语句中的 ORDER BY 和 LIMIT 自 4.1.0 版本起支持。 当前 UPDATE 语句仅支持在 UNIQUE KEY 模型上的行更新。 +如果既未指定 `WHERE` 也未指定 `LIMIT`,则会更新表中的所有行。请在省略 `WHERE` 子句前务必确认操作范围。 + ## 示例 `test` 表是一个 unique 模型的表,包含:k1, k2, v1, v2 四个列。其中 k1, k2 是 key,v1, v2 是 value,聚合方式是 Replace。 diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md index abb26530d2771..a4a362d2be3ca 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -40,7 +40,6 @@ DELETE FROM table_name + column_name: column belong to table_name + op: Logical comparison operator, The optional types of op include: =, >, <, >=, <=, !=, in, not in + value | value_list: value or value list used for logial comparison -+ WHERE condition: Specifies a condition to use to select rows for removal #### Optional Parameters @@ -48,8 +47,9 @@ DELETE FROM table_name + PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal + table_alias: alias of table + USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. ++ WHERE condition: Specifies a condition to use to select rows for removal. Required for Syntax 1. Optional for Syntax 2. + ORDER BY column: Specifies the order in which rows are deleted. Typically used together with LIMIT to control which rows are affected. -+ LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. ++ LIMIT [offset,] count: Limits the number of rows to be deleted. When used with ORDER BY, deletes the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before deleting. If used without ORDER BY, the set of affected rows is non-deterministic. :::tip ORDER BY and LIMIT in DELETE statements are supported since version 4.1.0. @@ -67,6 +67,7 @@ This feature is supported since the Apache Doris 1.2 version ::: 5. This statement may reduce query efficiency for a period of time after execution. The degree of impact depends on the number of delete conditions specified in the statement. The more conditions you specify, the greater the impact. +6. When neither `WHERE` nor `LIMIT` is specified in Syntax 2, all rows in the table will be deleted. Always verify the intended scope before omitting the `WHERE` clause. ## Example diff --git a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md index 484285c26e790..905a52353173f 100644 --- a/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md +++ b/versioned_docs/version-4.x/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -27,15 +27,15 @@ UPDATE target_table [table_alias] + target_table: The target table of the data to be updated. Can be of the form 'db_name.table_name' + assignment_list: The target column to be updated, in the format 'col_name = value, col_name = value' -+ where condition: the condition that is expected to be updated, an expression that returns true or false can be #### Optional Parameters + cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' + table_alias: alias of table + FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. ++ WHERE condition: The condition that is expected to be updated, an expression that returns true or false. + ORDER BY column: Specifies the order in which rows are updated. Typically used together with LIMIT to control which rows are affected. -+ LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. ++ LIMIT [offset,] count: Limits the number of rows to be updated. When used with ORDER BY, updates the first `count` rows after sorting. If `offset` is specified, skips the first `offset` rows before updating. If used without ORDER BY, the set of affected rows is non-deterministic. :::tip ORDER BY and LIMIT in UPDATE statements are supported since version 4.1.0. @@ -45,6 +45,8 @@ ORDER BY and LIMIT in UPDATE statements are supported since version 4.1.0. The current UPDATE statement only supports row updates on the UNIQUE KEY model. +When neither `WHERE` nor `LIMIT` is specified, all rows in the table will be updated. Always verify the intended scope before omitting the `WHERE` clause. + ## Example The `test` table is a unique model table, which contains four columns: k1, k2, v1, v2. Where k1, k2 are keys, v1, v2 are values, and the aggregation method is Replace.