I'm looking into ClickHouse's VIEW, MATERIALIZED VIEW and LIVE VIEW.
MATERIALIZED VIEW and LIVE VIEW are pretty well described in the official docs.
However, VIEW on a table description is limited. From the official docs:
As an example, assume you’ve created a view:
CREATE VIEW view AS SELECT ...
and written a query:
SELECT a, b, c FROM view
But it does not specify which table engines are supported for the table we are doing SELECT from. Also, there are no examples on usage. Can you please provide a minimum usage example of VIEW and explain which table engines are supported for the initial table?
Concerning the difference between the VIEW and MATERIALIZED VIEW types I found this answer for Oracle and it looks like it can be applied to ClickHouse as well What is the difference between Views and Materialized Views in Oracle?.
Edit: Added few essential examples from tests from the link in comments:
Example 1
DROP TABLE IF EXISTS union;
create view union as select 1 as test union all select 2;
SELECT * FROM union ORDER BY test;
DETACH TABLE union;
ATTACH TABLE union;
SELECT * FROM union ORDER BY test;
DROP TABLE union;
Example 2:
DROP VIEW IF EXISTS test_view;
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
f1 Int32,
f2 Int32,
pk Int32
)
ENGINE = MergeTree()
ORDER BY f1
PARTITION BY pk;
CREATE VIEW test_view AS
SELECT f1, f2
FROM test_table
WHERE pk = 2;
INSERT INTO test_table (f1, f2, pk) VALUES (1,1,1), (1,1,2), (2,1,1), (2,1,2);
SELECT * FROM test_view ORDER BY f1, f2;
ALTER TABLE test_view DELETE WHERE pk = 2; --{serverError 48}
SELECT * FROM test_view ORDER BY f1, f2;
DROP VIEW IF EXISTS test_view;
DROP TABLE IF EXISTS test_table;