Create partition table

  1. Description

    You can execute the CREATE PARTITION TABLE statement to create a partitioned table.

  2. Synopsis
    // Create a parent partition table.
    CREATE TABLE [IF NOT EXISTS] [schema_name.]table_name PARTITON BY list (column_name) ([
      {
       column_name column_type [column_constraints, [...]]
       | table_constraints
       [, ...]
      }
    ]);
    
    // Create a child partition table.
    CREATE TABLE [IF NOT EXISTS] [schema_name.]table_name PARTITION OF <parent_table>
        FOR VALUES IN (string_literal);
  3. Limitation
    1. No data can be inserted to the parent partitioned table.
    2. If you delete a parent partitioned table, the related child partitioned tables are also deleted.
    3. Only a field of the TEXT, VARCHAR, or INT type can be used as a partition key.
    4. You can use a partition rule to create only one partitioned table.
    5. Only Partition By List is supported and you can specify only one field in List.
  4. Examples
    BEGIN;
    CREATE TABLE hologres_parent(a text primary key,
     b int NOT NULL , 
     c TIMESTAMPTZ NOT NULL , 
     d text)
     PARTITION BY list(a);
    call set_table_property('hologres_parent', 'orientation', 'column');
    call set_table_property('hologres_parent', 'clustering_key', 'a,b'); 
    call set_table_property('hologres_parent', 'segment_key', 'c');
    call set_table_property('hologres_parent', 'bitmap_columns', 'a,d'); 
    call set_table_property('hologres_parent', 'dictionary_encoding_columns', 'a,d'); 
    call set_table_property('hologres_parent', 'time_to_live_in_seconds', '86400');
    
    CREATE TABLE hologres_child2 PARTITION of hologres_parent FOR VALUES IN('b');
    CREATE TABLE hologres_child3 PARTITION of hologres_parent FOR VALUES IN('c');
    CREATE TABLE hologres_child1 PARTITION of hologres_parent FOR VALUES IN('a');
    COMMIT;

Drop partition table

The syntax of the statement for deleting a partitioned table is the same as that for dropping a standard table. For more information, see DROP TABLE.

Examples
DROP TABLE hologres_child2;