KEY-RANGE
Syntax
The following statement is used to create one or more KEY-RANGE partitioned tables where each partition may contain one or more subpartitions:
CREATE TABLE [ schema. ]table_name table_definition PARTITION BY [LINEAR] KEY (column_list) SUBPARTITION BY RANGE {(expr) | COLUMNS(column_list)} (partition_definition [, partition_definition] ...);
partition_definition is:
PARTITION partition_name (subpartition_definition [, subpartition_definition] ...)
subpartition_definition is:
SUBPARTITION subpartition_name VALUES LESS THAN {value | value_list | MAXVALUE}
Parameter |
Description |
---|---|
table_name |
The name of the table to be created. |
expr |
The expression of the partition. Currently, only the INT type is supported. |
column_list |
The list of partition key columns. It is used in RANGE COLUMNS(). Expressions are not supported. |
value |
The boundary value of the partition. |
value_list |
The list of the values of the partition key columns. It is used in LIST COLUMNS(). |
MAXVALUE |
The maximum value of the partition. |
partition_name subpartition_name |
The name of the partition. The name must be unique within the table. The name of the subpartition. The name must be unique within the table. |
Example
Create a KEY-RANGE partitioned table:
CREATE TABLE tbl_key_range ( col1 INT, col2 INT, col3 varchar(20), col4 DATE ) PARTITION BY KEY(col1) SUBPARTITION BY RANGE COLUMNS(col4) ( PARTITION p0( SUBPARTITION p0_q1_2023 VALUES LESS THAN('2023-04-01'), SUBPARTITION p0_q2_2023 VALUES LESS THAN('2023-07-01'), SUBPARTITION p0_q3_2023 VALUES LESS THAN('2023-10-01'), SUBPARTITION p0_q4_2023 VALUES LESS THAN('2024-01-01') ), PARTITION p1( SUBPARTITION p1_q1_2023 VALUES LESS THAN('2023-04-01'), SUBPARTITION p1_q2_2023 VALUES LESS THAN('2023-07-01'), SUBPARTITION p1_q3_2023 VALUES LESS THAN('2023-10-01'), SUBPARTITION p1_q4_2023 VALUES LESS THAN('2024-01-01') ), PARTITION p2( SUBPARTITION p2_q1_2023 VALUES LESS THAN('2023-04-01'), SUBPARTITION p2_q2_2023 VALUES LESS THAN('2023-07-01'), SUBPARTITION p2_q3_2023 VALUES LESS THAN('2023-10-01'), SUBPARTITION p2_q4_2023 VALUES LESS THAN('2024-01-01') ) );
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot