You can create a table group with the SHARDING attribute as needed.
Limitations
It is prohibited to create table groups during the upgrade of OceanBase Database.
Create a table group
To create a table group, you must have the global CREATE (*.*) privilege. The SQL syntax for creating a table group is as follows:
CREATE TABLEGROUP tablegroup_name [tablegroup_option];
tablegroup_option:
SHARDING = 'NONE'
SHARDING = 'PARTITION'
SHARDING = 'ADAPTIVE'
The parameters in the syntax are described as follows:
tablegroup_name: the name of the table group to be created.SHARDING: theSHARDINGattribute of the table group. The requirements on tables in a table group vary based on the attribute value. If you do not specify theSHARDINGattribute, an'ADAPTIVE'table group is created by default.SHARDING = 'NONE': No restrictions are imposed on tables added to the table group.SHARDING = 'PARTITION': A table to be added to the table group must have the same partition definition as existing tables in the table group, including the partitioning type, partition count, and partition value.Specifically, the same partition definition is described as follows:
- Tables in the table group have the same partitioning type, such as RANGE partitioning.
- HASH-partitioned tables have the same number of referenced columns and the same number of partitions.
- RANGE-partitioned tables have the same number of referenced columns, the same number of partitions, and the same range definition.
SHARDING = 'ADAPTIVE': A table to be added to the table group must have the same partition and subpartition definitions as existing tables in the table group, including the partitioning type, partition count, and partition value.Specifically, the same partition definition is described as follows:
- Tables in the table group have the same partitioning type such as HASH-RANGE partitioning.
- HASH-partitioned tables have the same number of referenced columns and the same number of partitions.
- RANGE-partitioned tables have the same number of referenced columns, the same number of partitions, and the same range definition.
- The requirements on subpartitions are the same as those on partitions, depending on the partitioning type.
The following example shows how to create a table group:
CREATE TABLEGROUP tblgroup1 SHARDING = 'NONE';
What to do next
After you create a table group, you can add existing tables that meet specific conditions to the table group. For more information, see Add tables to a table group.