云数据库 GAUSSDB(FOR MYSQL)-KEY-RANGE:使用示例

时间:2024-08-02 14:04:08

使用示例

KEY-RANGE类型的使用示例

CREATE TABLE tbl_key_range
(
    col1 INT,
    col2 INT,
    col3 varchar(20),
    col4 DATE
)
PARTITION BY KEY(col1)
    SUBPARTITION BY RANGE COLUMNS(col4)
(
  PARTITION  p0(
    SUBPARTITION p0_q1_2023 VALUES LESS THAN('2023-04-01'),
    SUBPARTITION p0_q2_2023 VALUES LESS THAN('2023-07-01'),
    SUBPARTITION p0_q3_2023 VALUES LESS THAN('2023-10-01'),
    SUBPARTITION p0_q4_2023 VALUES LESS THAN('2024-01-01')
  ),
  PARTITION  p1(
    SUBPARTITION p1_q1_2023 VALUES LESS THAN('2023-04-01'),
    SUBPARTITION p1_q2_2023 VALUES LESS THAN('2023-07-01'),
    SUBPARTITION p1_q3_2023 VALUES LESS THAN('2023-10-01'),
    SUBPARTITION p1_q4_2023 VALUES LESS THAN('2024-01-01')
    ),
  PARTITION  p2(
    SUBPARTITION p2_q1_2023 VALUES LESS THAN('2023-04-01'),
    SUBPARTITION p2_q2_2023 VALUES LESS THAN('2023-07-01'),
    SUBPARTITION p2_q3_2023 VALUES LESS THAN('2023-10-01'),
    SUBPARTITION p2_q4_2023 VALUES LESS THAN('2024-01-01')
  )
);
support.huaweicloud.com/usermanual-gaussdbformysql/gaussdbformysql_05_0331.html