You can create a table group with the SHARDING attribute based on your business requirements.
Limitations
Creating a table group is prohibited during an OceanBase AI Database upgrade.
Create a table group
Creating a table group requires the current user to have the global CREATE (*.*) privilege. The SQL statement for creating a table group is as follows:
CREATE TABLEGROUP tablegroup_name [tablegroup_option];
tablegroup_option:
SHARDING = 'NONE'
SHARDING = 'PARTITION'
SHARDING = 'ADAPTIVE'
SHARDING = 'SUBPARTITION'
The parameters are described as follows:
tablegroup_name: The name of the table group to be created.SHARDING: The attribute of the table group. Different attribute values have different requirements for the tables in the table group. If theSHARDINGattribute is not specified, a table group withSHARDING = 'ADAPTIVE'is created by default.SHARDING = 'NONE': Indicates that there are no restrictions on the tables to be added to the table group.SHARDING = 'PARTITION': All tables added to the table group must have primary partitions whose partition definition is the same as that of the primary partitions of all tables in the table group, including the partition type, number of partitions, and partition values.Identical partition definitions specifically refer to:
- The same partition type, for example, both are RANGE partitions.
- For HASH partitions, the same number of columns and the same number of partitions are required.
- For RANGE partitions, the same number of columns, the same number of partitions, and the same RANGE split points are required.
SHARDING = 'ADAPTIVE': All tables added to the table group must have primary partitions and subpartitions whose partition and subpartition definitions are the same as those of all tables in the table group, including the partition type, number of partitions, and partition values.Identical partition and subpartition definitions specifically refer to:
- The same partition type, for example, both are HASH + RANGE partitions.
- For HASH partitions, the same number of columns and the same number of partitions are required.
- For RANGE partitions, the same number of columns, the same number of partitions, and the same RANGE split points are required.
- For subpartitions, the requirements are the same as those for partitions based on their partition type.
SHARDING = 'SUBPARTITION': Requires that all tables added to the table group must be subpartitioned tables. The partitioning methods of the primary partitions and subpartitions must be the same across different tables, including the partitioning key type, partitioning function, number of partitions, and partition boundary values.
The following examples show how to create a table group:
CREATE TABLEGROUP tblgroup1 SHARDING = 'NONE';
CREATE TABLEGROUP tblgroup5 SHARDING = 'SUBPARTITION';
What to do next
After creating a table group, you can add existing tables that meet the criteria to the table group. For more information, see Add tables to a table group.