Updated on 2024-09-06 GMT+08:00

HASH-LIST

Syntax

The following statement is used to create one or more HASH-LIST partitioned tables where each partition may contain one or more subpartitions:

CREATE TABLE [ schema. ]table_name
 table_definition
 PARTITION BY [LINEAR] HASH(expr)
   SUBPARTITION BY LIST {(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 IN (value_list)
Table 1 Parameters

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 LIST COLUMNS(). Expressions are not supported.

value_list

The list of the values of the partition key columns. It is used in LIST COLUMNS().

partition_name

The name of the partition. The name must be unique within the table.

subpartition_name

The name of the subpartition. The name must be unique within the table.

Example

Create a HASH-LIST partitioned table:
CREATE TABLE tbl_hash_list
(
    col1 INT,
    col2 INT,
    col3 varchar(20),
    col4 DATE
)
PARTITION BY HASH(col1)
SUBPARTITION BY LIST(col2)
(
  PARTITION dp0 (
    SUBPARTITION p0 VALUES in (1, 2),
    SUBPARTITION p1 VALUES in (3, 4),
    SUBPARTITION p2 VALUES in (5, 6)
  ),
  PARTITION dp1
  (
    SUBPARTITION p3 VALUES in (1, 2),
    SUBPARTITION p4 VALUES in (3, 4),
    SUBPARTITION p5 VALUES in (5, 6)
  ),
  PARTITION dp2
  (
    SUBPARTITION p6 VALUES in (1, 2),
    SUBPARTITION p7 VALUES in (3, 4),
    SUBPARTITION p8 VALUES in (5, 6)
  )
);