Skip to content

Commit

Permalink
partitioned-table: create strictly increasing range columns partition (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 25, 2024
1 parent bc0c51a commit 5a17a66
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ Range partitioning is particularly useful when one or more of the following cond

Range COLUMNS partitioning is a variant of Range partitioning. You can use one or more columns as partitioning keys. The data types of partition columns can be integer, string (`CHAR` or `VARCHAR`), `DATE`, and `DATETIME`. Any expressions, such as non-COLUMNS partitioning, are not supported.

Like Range partitioning, Range COLUMNS partitioning also requires the partition ranges to be strictly increasing. The partition definition in the following example is not supported:

```sql
CREATE TABLE t(
a int,
b datetime,
c varchar(8)
) PARTITION BY RANGE COLUMNS(`c`,`b`)
(PARTITION `p20240520A` VALUES LESS THAN ('A','2024-05-20 00:00:00'),
PARTITION `p20240520Z` VALUES LESS THAN ('Z','2024-05-20 00:00:00'),
PARTITION `p20240521A` VALUES LESS THAN ('A','2024-05-21 00:00:00'));
```

```
Error 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition
```

Suppose that you want to partition by name, and drop old and invalid data, then you can create a table as follows:

```sql
Expand Down

0 comments on commit 5a17a66

Please sign in to comment.