Skip to content

Commit dd1ca6c

Browse files
dataroaringVallishpCopilot
committed
[Enhancement] Support move truncated old data to recycle bin (#3380)
## Summary - Recreate the TRUNCATE documentation update from #1324 for `dev` and `4.x`. - Document `FORCE` syntax and add recovery behavior notes with `RECOVER` references. - Apply updates to both English and Chinese docs. ## Versions - [x] dev - [x] 4.x - [ ] 3.x - [ ] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Reference - Original PR: #1324 --------- Co-authored-by: Vallish <vallishpai@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 374d47f commit dd1ca6c

4 files changed

Lines changed: 50 additions & 38 deletions

File tree

docs/data-operate/delete/truncate-manual.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@ Use this statement to clear data from a specified table and its partitions.
1313
## Syntax
1414

1515
```sql
16-
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)];
16+
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)] [FORCE];
1717
```
1818

19-
- This statement clears the data but retains the table or partition structure.
20-
21-
- Unlike DELETE, TRUNCATE only performs metadata operations, making it faster and not affecting query performance.
22-
23-
- Data removed by this operation cannot be recovered.
24-
25-
- The table status must be NORMAL, and there should be no ongoing SCHEMA CHANGE operations.
26-
27-
- This command may cause ongoing import tasks to fail.
19+
- This statement only clears the data within a table or partition but preserves the table or partition itself.
20+
- Unlike DELETE, this statement can only clear the specified table or partition as a whole and cannot be added with filter conditions.
21+
- Unlike DELETE, truncating data will not affect query performance.
22+
- The data deleted by this operation can be recovered through the RECOVER statement (for a period of time). See [RECOVER](../../sql-manual/sql-statements/recycle/RECOVER) statement for details. If you execute the command with FORCE, the data will be deleted directly and cannot be recovered. This operation is generally not recommended.
23+
- When using this command, the table status must be NORMAL, which means that tables undergoing SCHEMA CHANGE cannot be truncated.
24+
- This command may cause ongoing imports to fail.
2825

2926
## Examples
3027

@@ -39,3 +36,9 @@ TRUNCATE TABLE example_db.tbl;
3936
```sql
4037
TRUNCATE TABLE tbl PARTITION(p1, p2);
4138
```
39+
40+
**3. Clear the table `tbl` in the `example_db` database with FORCE**
41+
42+
```sql
43+
TRUNCATE TABLE example_db.tbl FORCE;
44+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/delete/truncate-manual.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@
1111
## 语法
1212

1313
```sql
14-
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)];
14+
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)] [FORCE];
1515
```
1616

17-
- 该语句清空数据,但保留表或分区结构。
18-
19-
- 与 DELETE 不同,TRUNCATE 仅进行元数据操作,速度快且不会影响查询性能。
20-
21-
- 该操作删除的数据不可恢复。
22-
23-
- 表状态需为 NORMAL,不能有正在进行的 SCHEMA CHANGE 等操作。
24-
17+
- 该语句仅清空表或分区中的数据,但保留表或分区本身。
18+
- 与 DELETE 不同,该语句只能整体清空指定表或分区,不支持附加过滤条件。
19+
- 与 DELETE 不同,TRUNCATE 清空数据不会影响查询性能。
20+
- 该操作删除的数据可通过 RECOVER 语句在一定时间内恢复。详见 [RECOVER](../../sql-manual/sql-statements/recycle/RECOVER) 语句说明。若执行命令时使用 FORCE,数据将被直接删除且不可恢复,通常不建议使用。
21+
- 使用该命令时,表状态必须为 NORMAL,即正在进行 SCHEMA CHANGE 的表不能执行 TRUNCATE。
2522
- 该命令可能会导致正在进行的导入任务失败。
2623

2724
## 示例
@@ -37,3 +34,9 @@ TRUNCATE TABLE example_db.tbl;
3734
```sql
3835
TRUNCATE TABLE tbl PARTITION(p1, p2);
3936
```
37+
38+
**3. 使用 FORCE 清空 example_db 下的表 tbl**
39+
40+
```sql
41+
TRUNCATE TABLE example_db.tbl FORCE;
42+
```

i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/data-operate/delete/truncate-manual.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@
1111
## 语法
1212

1313
```sql
14-
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)];
14+
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)] [FORCE];
1515
```
1616

17-
- 该语句清空数据,但保留表或分区结构。
18-
19-
- 与 DELETE 不同,TRUNCATE 仅进行元数据操作,速度快且不会影响查询性能。
20-
21-
- 该操作删除的数据不可恢复。
22-
23-
- 表状态需为 NORMAL,不能有正在进行的 SCHEMA CHANGE 等操作。
24-
17+
- 该语句仅清空表或分区中的数据,但保留表或分区本身。
18+
- 与 DELETE 不同,该语句只能整体清空指定表或分区,不支持附加过滤条件。
19+
- 与 DELETE 不同,TRUNCATE 清空数据不会影响查询性能。
20+
- 该操作删除的数据可通过 RECOVER 语句在一定时间内恢复。详见 [RECOVER](../../sql-manual/sql-statements/recycle/RECOVER) 语句说明。若执行命令时使用 FORCE,数据将被直接删除且不可恢复,通常不建议使用。
21+
- 使用该命令时,表状态必须为 NORMAL,即正在进行 SCHEMA CHANGE 的表不能执行 TRUNCATE。
2522
- 该命令可能会导致正在进行的导入任务失败。
2623

2724
## 示例
@@ -37,3 +34,9 @@ TRUNCATE TABLE example_db.tbl;
3734
```sql
3835
TRUNCATE TABLE tbl PARTITION(p1, p2);
3936
```
37+
38+
**3. 使用 FORCE 清空 example_db 下的表 tbl**
39+
40+
```sql
41+
TRUNCATE TABLE example_db.tbl FORCE;
42+
```

versioned_docs/version-4.x/data-operate/delete/truncate-manual.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@ Use this statement to clear data from a specified table and its partitions.
1313
## Syntax
1414

1515
```sql
16-
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)];
16+
TRUNCATE TABLE [db.]tbl [PARTITION(p1, p2, ...)] [FORCE];
1717
```
1818

19-
- This statement clears the data but retains the table or partition structure.
20-
21-
- Unlike DELETE, TRUNCATE only performs metadata operations, making it faster and not affecting query performance.
22-
23-
- Data removed by this operation cannot be recovered.
24-
25-
- The table status must be NORMAL, and there should be no ongoing SCHEMA CHANGE operations.
26-
27-
- This command may cause ongoing import tasks to fail.
19+
- This statement only clears the data within a table or partition but preserves the table or partition itself.
20+
- Unlike DELETE, this statement can only clear the specified table or partition as a whole and cannot be added with filter conditions.
21+
- Unlike DELETE, truncating data will not affect query performance.
22+
- The data deleted by this operation can be recovered through the RECOVER statement (for a period of time). See [RECOVER](../../sql-manual/sql-statements/recycle/RECOVER) statement for details. If you execute the command with FORCE, the data will be deleted directly and cannot be recovered. This operation is generally not recommended.
23+
- When using this command, the table status must be NORMAL, which means that tables undergoing SCHEMA CHANGE cannot be truncated.
24+
- This command may cause ongoing imports to fail.
2825

2926
## Examples
3027

@@ -39,3 +36,9 @@ TRUNCATE TABLE example_db.tbl;
3936
```sql
4037
TRUNCATE TABLE tbl PARTITION(p1, p2);
4138
```
39+
40+
**3. Clear the table `tbl` in the `example_db` database with FORCE**
41+
42+
```sql
43+
TRUNCATE TABLE example_db.tbl FORCE;
44+
```

0 commit comments

Comments
 (0)