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

时间:2024-09-11 14:19:51

使用示例

  • RANGE-LIST类型的使用示例
    CREATE TABLE tbl_range_list (col1 INT, col2 INT, col3 varchar(20))
    PARTITION BY RANGE(col1)
        SUBPARTITION BY LIST(col2)
    (
      PARTITION m1 VALUES LESS THAN(1000) (
        SUBPARTITION p0 VALUES in (1, 2),
    	SUBPARTITION p1 VALUES in (3, 4),
    	SUBPARTITION p2 VALUES in (5, 6)
      ),
      PARTITION m2 VALUES LESS THAN(2000) (
        SUBPARTITION p3 VALUES in (1, 2),
    	SUBPARTITION p4 VALUES in (3, 4),
    	SUBPARTITION p5 VALUES in (5, 6)
      ),
      PARTITION m3 VALUES LESS THAN(MAXVALUE) (
        SUBPARTITION p6 VALUES in (1, 2),
    	SUBPARTITION p7 VALUES in (3, 4),
    	SUBPARTITION p8 VALUES in (5, 6)
      )
    );
  • RANGE COLUMNS-LIST类型的使用示例
    CREATE TABLE tbl_range_columns_list
    (
        col1 INT,
        col2 INT,
        col3 varchar(20),
        col4 DATE
    )
    PARTITION BY RANGE COLUMNS(col4)
    	SUBPARTITION BY LIST(col1)
    (
      PARTITION dp1 VALUES LESS THAN('2023-01-01')(
        SUBPARTITION p0 VALUES in (1, 2),
        SUBPARTITION p1 VALUES in (3, 4),
        SUBPARTITION p2 VALUES in (5, 6)
      ),
      PARTITION dp2 VALUES LESS THAN('2024-01-01')(
        SUBPARTITION p3 VALUES in (1, 2),
        SUBPARTITION p4 VALUES in (3, 4),
        SUBPARTITION p5 VALUES in (5, 6)
      ),
      PARTITION dp3 VALUES LESS THAN('2025-01-01')(
        SUBPARTITION p6 VALUES in (1, 2),
        SUBPARTITION p7 VALUES in (3, 4),
        SUBPARTITION p8 VALUES in (5, 6)
      )
    );
support.huaweicloud.com/kerneldesc-gaussdbformysql/gaussdbformysql_20_0039.html