创建列存储表
要创建列存储表,需要将表的访问方式(Table Access Method) 设为 PAX,在建表时显式使用 USING PAX 子句指定表访问方式
teledb=# CREATE TABLE t1(a int, b int, c text) USING PAX;
CREATE TABLE
teledb=# \d+ t1
Table "public.t1"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
a | integer | | | | plain | |
b | integer | | | | plain | |
c | text | | | | extended | |
Distribute By: HASH(a)
Location Nodes: ALL DATANODES
查看列存储表访问方式
查询系统目录表pg_class 和 pg_am 检查列存储表的访问方式
teledb=# SELECT relname, amname FROM pg_class, pg_am WHERE relam = pg_am.oid AND relname = 't1';
relname | amname
---------+--------
t1 | pax
(1 row)
删除列存储表
删除列存储表和行存表语法一致,使用drop table 语句删除
teledb=# drop table t1;
DROP TABLE