Create a table group

2024-03-05 01:54:26  Updated

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

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'

where

  • tablegroup_name specifies the name of the table group to be created.

  • SHARDING specifies the SHARDING attribute of the table group. The requirements on tables in a table group vary based on the attribute value. If the SHARDING attribute is not specified, a table group with SHARDING = 'ADAPTIVE' is created by default.

    • SHARDING = 'NONE' indicates that there are no limitations on tables to be added to the table group.

    • SHARDING = 'PARTITION' requires that all tables to be added to the table group have the same partition definition, including the partitioning type, partition count, and partition value.

      Specifically, the same partition definition means that:

      • 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' requires that all tables to be added to the table group have the same partition definition and subpartition definition as existing tables in the table group, including the partitioning type, partition count, and partition value.

      Specifically, the same partition definition means that:

      • 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.

References

Contact Us