创建列存储分区表
 
                  更新时间 2025-02-05 09:36:50
                 
 
                    最近更新时间: 2025-02-05 09:36:50
                  
 本页介绍天翼云TeleDB数据库创建列存储分区表的语法。
 列存储引擎中分区表主表作为逻辑表仍是行存结果,实际存储数据的分区表需要指定使用USING PAX 命令创建,创建一个 HASH 分区的列存储分区表如下:
teledb=# create table test_hash ( 
teledb(#     "userid" int4 not null, 
teledb(#     "name" varchar(64))
teledb-# partition by hash(userid);
CREATE TABLE
teledb=# create table test_hash_c1 partition of test_hash for values WITH (modulus 4, remainder 0) using pax;
CREATE TABLE
teledb=# create table test_hash_c2 partition of test_hash for values WITH (modulus 4, remainder 1) using pax;
CREATE TABLE
teledb=# create table test_hash_c3 partition of test_hash for values WITH (modulus 4, remainder 2) using pax;
CREATE TABLE
teledb=# create table test_hash_c4 partition of test_hash for values WITH (modulus 4, remainder 3) using pax;
CREATE TABLE
teledb=# \d+ test_hash
                                        Table "public.test_hash"
 Column |         Type          | Collation | Nullable | Default | Storage  | Stats target | Description 
--------+-----------------------+-----------+----------+---------+----------+--------------+-------------
 userid | integer               |           | not null |         | plain    |              | 
 name   | character varying(64) |           |          |         | extended |              | 
Partition key: HASH (userid)
Partitions: test_hash_c1 FOR VALUES WITH (modulus 4, remainder 0),
            test_hash_c2 FOR VALUES WITH (modulus 4, remainder 1),
            test_hash_c3 FOR VALUES WITH (modulus 4, remainder 2),
            test_hash_c4 FOR VALUES WITH (modulus 4, remainder 3)
Distribute By: HASH(userid)
Location Nodes: ALL DATANODES
