-- 建立父表,子表继承,数据插入到子表。查询所有时,只查询父表即可;查询子表,则可以减轻压力。
-- 创建父表
CREATE TABLE open.t_log_info(
f_date integer,
f_action integer,
f_uid bigint,
f_note character varying(255)
)
WITH (appendonly=true) DISTRIBUTED BY (f_date, f_action);
-- 创建子表 子表自动继承父表的所有字段 通过 INHERITS 指定继承的父表
CREATE TABLE open.t_log_info_20200927()
INHERITS (open.t_log_info)
WITH (appendonly=true) DISTRIBUTED BY (f_date, f_action);
insert into open.t_log_info values (1,1,1,'a');
insert into open.t_log_info_20200927 values (1,1,1,'b');
select * from open.t_log_info; -- 两条数据
select * from open.t_log_info_20200927; -- 一条数据