All Products
Search
Document Center

ApsaraDB for OceanBase:Create partitions

Last Updated:Jun 03, 2024

This topic describes the supported conversion scope of CREATE TABLE DDL operations for creating partitions during data migration from a MySQL database to a MySQL tenant of OceanBase Database.

Syntax

partition_options:
    PARTITION BY
        { [LINEAR] HASH(expr)
        | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)
        | RANGE{(expr) | COLUMNS(column_list)}
        | LIST{(expr) | COLUMNS(column_list)} }
    [PARTITIONS num]
    [SUBPARTITION BY
        { [LINEAR] HASH(expr)
        | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list) }
      [SUBPARTITIONS num]
    ]
    [(partition_definition [, partition_definition] ...)]

partition_definition:
    PARTITION partition_name
        [VALUES
            {LESS THAN {(expr | value_list) | MAXVALUE}
            |
            IN (value_list)}]
        [[STORAGE] ENGINE [=] engine_name]
        [COMMENT [=] 'string' ]
        [DATA DIRECTORY [=] 'data_dir']
        [INDEX DIRECTORY [=] 'index_dir']
        [MAX_ROWS [=] max_number_of_rows]
        [MIN_ROWS [=] min_number_of_rows]
        [TABLESPACE [=] tablespace_name]
        [(subpartition_definition [, subpartition_definition] ...)]

subpartition_definition:
    SUBPARTITION logical_name
        [[STORAGE] ENGINE [=] engine_name]
        [COMMENT [=] 'string' ]
        [DATA DIRECTORY [=] 'data_dir']
        [INDEX DIRECTORY [=] 'index_dir']
        [MAX_ROWS [=] max_number_of_rows]
        [MIN_ROWS [=] min_number_of_rows]
        [TABLESPACE [=] tablespace_name]

Supported operations

  • Create RANGE, LIST, HASH, or KEY partitions.

  • Create HASH or KEY subpartitions.

  • Specify a function partitioning key (an expression or a function) or a column partitioning key (a field) for RANGE, LIST, and HASH partitions. Specify a column partitioning key for KEY partitions.

  • Specify the PARTITIONS num and SUBPARTITIONS num options.

Unsupported operations

Create LINEAR HASH or LINEAR KEY partitions.

Important

If the synchronized DDL statement for creating a partition contains unsupported definitions, the partition definition generated will be empty, but the table schema is retained (with the partition definition discarded).

Ignored clauses and options

Important

The following clauses and options will be ignored and will not be resolved or converted when they are specified in the synchronized DDL statements.

  • ENGINE

  • COMMENT

  • DATA DIRECTORY

  • INDEX DIRECTORY

  • MAX_ROWS

  • MIN_ROWS

  • TABLESPACE

  • ALGORITHM (for KEY partitions)

    PARTITION BY KEY ALGORITHM={1 | 2} (column_list) -> PARTITION BY KEY (column_list)

Limits

Important

Due to the limits of MySQL tenants of OceanBase Database, an error may be returned when the synchronized DDL statements are converted and executed in a MySQL tenant of OceanBase Database in the following scenarios:

  • MySQL tenants of OceanBase Database do not support using fields of certain types as the partitioning key.

  • MySQL tenants of OceanBase Database do not support using certain functions or expressions as the partitioning key.