Skip to content

Commit

Permalink
add translation
Browse files Browse the repository at this point in the history
Signed-off-by: Ran <[email protected]>
  • Loading branch information
ran-huang authored and ti-chi-bot committed Jul 6, 2023
1 parent 537c92a commit da375f3
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,16 @@ CREATE TABLE t (
name varchar(255) CHARACTER SET ascii,
notes text
)
PARTITION BY RANGE COLUMNS(name,valid_until)
PARTITION BY RANGE COLUMNS(name, valid_until)
(PARTITION `p2022-g` VALUES LESS THAN ('G','2023-01-01 00:00:00'),
PARTITION `p2023-g` VALUES LESS THAN ('G','2024-01-01 00:00:00'),
PARTITION `p2024-g` VALUES LESS THAN ('G','2025-01-01 00:00:00'),
PARTITION `p2022-m` VALUES LESS THAN ('M','2023-01-01 00:00:00'),
PARTITION `p2023-m` VALUES LESS THAN ('M','2024-01-01 00:00:00'),
PARTITION `p2024-m` VALUES LESS THAN ('M','2025-01-01 00:00:00'),
PARTITION `p2022-s` VALUES LESS THAN ('S','2023-01-01 00:00:00'),
PARTITION `p2023-s` VALUES LESS THAN ('S','2024-01-01 00:00:00'),
PARTITION `p2024-s` VALUES LESS THAN ('S','2025-01-01 00:00:00'),
PARTITION `p2022-` VALUES LESS THAN (0x7f,'2023-01-01 00:00:00'),
PARTITION `p2023-` VALUES LESS THAN (0x7f,'2024-01-01 00:00:00'),
PARTITION `p2024-` VALUES LESS THAN (0x7f,'2025-01-01 00:00:00'))
PARTITION `p2023-s` VALUES LESS THAN ('S','2024-01-01 00:00:00'))
```

It will partition the data by year and by name in the ranges ['', 'G'), ['G', 'M'), ['M', 'S') and ['S',). It allows you to easily drop invalid data while still benefit from partition pruning on both `name` and `valid_until` columns. In this example, `[,)` indicates a left-closed, right-open range. For example, ['G', 'M') indicates a range containing `G` and from `G` to `M`, but excluding `M`.
The preceding SQL statement will partition the data by year and by name in the ranges `[ ('', ''), ('G', '2023-01-01 00:00:00') )`, `[ ('G', '2023-01-01 00:00:00'), ('G', '2024-01-01 00:00:00') )`, `[ ('G', '2024-01-01 00:00:00'), ('M', '2023-01-01 00:00:00') )`, `[ ('M', '2023-01-01 00:00:00'), ('M', '2024-01-01 00:00:00') )`, `[ ('M', '2024-01-01 00:00:00'), ('S', '2023-01-01 00:00:00') )`, and `[ ('S', '2023-01-01 00:00:00'), ('S', '2024-01-01 00:00:00') )`. It allows you to easily drop invalid data while still benefit from partition pruning on both `name` and `valid_until` columns. In this example, `[,)` indicates a left-closed, right-open range. For example, `[ ('G', '2023-01-01 00:00:00'), ('G', '2024-01-01 00:00:00') )` indicates a range of data whose name is `'G'`, the year contains `2023-01-01 00:00:00` and is greater than `2023-01-01 00:00:00` but less than `2024-01-01 00:00:00`. It does not include `(G, 2024-01-01 00:00:00)`.

### Range INTERVAL partitioning

Expand Down Expand Up @@ -810,8 +804,8 @@ For Key partitioning, the way of handling `NULL` value is consistent with that o

For `RANGE`, `RANGE COLUMNS`, `LIST`, and `LIST COLUMNS` partitioned tables, you can manage the partitions as follows:

- Add partitions using the `ALTER TABLE <table name> ADD PARTITION (<partition specification>)` statement.
- Drop partitions using the `ALTER TABLE <table name> DROP PARTITION <list of partitions>` statement.
- Add partitions using the `ALTER TABLE <table name> ADD PARTITION (<partition specification>)` statement.
- Drop partitions using the `ALTER TABLE <table name> DROP PARTITION <list of partitions>` statement.
- Remove all data from specified partitions using the `ALTER TABLE <table name> TRUNCATE PARTITION <list of partitions>` statement. The logic of `TRUNCATE PARTITION` is similar to [`TRUNCATE TABLE`](/sql-statements/sql-statement-truncate.md) but it is for partitions.
- Merge, split, or make other changes to the partitions using the `ALTER TABLE <table name> REORGANIZE PARTITION <list of partitions> INTO (<new partition definitions>)` statement.

Expand Down

0 comments on commit da375f3

Please sign in to comment.