CREATE/DROP PARTITION TABLE¶
create partition table¶
Introduction¶
create partition table:create Hologres partition tables.
Synopsis¶
-- "create partition table" format
create table [if not exists] [schema_name.]table_name partition by list (column_name) ([
{
column_name column_type [column_constraints, [...]]
| table_constraints
[, ...]
}
]);
-- typical create child partition table exmaple:
create table [if not exists] [schema_name.]table_name partition of parent_table
for values in (string_literal);
Limitation¶
- Can not insert any data into parent table.
- Drop the parent table will cascade to also drop the child table (the partition table)
- Partition key column must be of text/varchar/int type.
- One partition rule for one partition table.
- partition by also supports list, only one value can be used to split the partition list.
Example¶
begin;
create table hologres_parent(a text primary key, b int, c timestamp, 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_child1 partition of hologres_parent for values in('a');
create table hologres_child2 partition of hologres_parent for values in('b');
create table hologres_child3 partition of hologres_parent for values in('c');
commit;
drop partition table¶
DROP PARTITION TABLE is similar to DROP TABLE.