pipelinedb 常用sql语句
-- 创建普通表
create table simple_user (name varchar(80), age int , phone varchar(30), birthday date );
-- 创建Stream
create foreign table simple_user_stream (name varchar(80), age int , phone varchar(30), birthday date ) server pipelinedb;
-- 流中插入数据
insert into simple_user_stream(name,age,phone,birthday) values('test',100,'18780888888',now());
-- 例子1: 普通视图
create view simple_view as select name , age , phone ,birthday from simple_user;
-- 创建连续视图
create continuous view simple_continuous_view as select name , age , phone ,birthday from simple_user_stream;
-- 创建带ttl的连续视图 , 存储时间超过1分就删除
create continuous view simple_continuous_view with(ttl='2 minute',ttl_column='minute')
as select minute(arrival_timestamp) ,name , age , phone ,birthday from simple_user_stream;
-- 查看连续视图的数据
select * from public.simple_continuous_view;
-- 清空连续视图的数据
select truncate_continuous_view('simple_continuous_view');
-- 删除连续视图
drop view simple_continuous_view;
-- 查看系统中所有连续视图
select * from pipeline_views();
-- 激活连续视图
select activate('simple_continuous_view');
-- 关闭连续视图
select deactivate('simple_continuous_view');
相关文章