假设我们有一个像这样的表 test_table
create table test_table(x integer);
是否可以从此表创建连续视图?像这样的东西:
create continuous view test_view as select sum(x) as x_sum from test_table;
当我运行上面的命令时,我得到了错误:
test=# 创建连续视图 test_view as select sum(x) as x_sum from test_table; 错误:连续查询必须在 FROM 子句第 1 行中包含流: ...ous view test_view as select sum(x) as x_sum from test_table... ^ 提示:要在连续查询中包含关系,请使用溪流。
这是文档:
以下是创建连续视图的语法:
CREATE CONTINUOUS VIEW name AS query
其中 query 是 PostgreSQL SELECT 语句的子集:
SELECT [ DISTINCT [ ON ( expression [, ...] ) ] ]
expression [ [ AS ] output_name ] [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ GROUP BY expression [, ...] ]
[ HAVING condition [, ...] ]
[ WINDOW window_name AS ( window_definition ) [, ...] ]
其中 from_item 可以是以下之一:
stream_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
table_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
from_item [ NATURAL ] join_type from_item [ ON join_condition ]
根据这个 from_item 也可以是一个表。文档有错吗?如果无法从表中创建连续视图,是否有办法将当前数据从表中加载到某个流中。