How to Create a View in ClickHouse
This example creates a view called my_view
for query SELECT * FROM my_table
:
CREATE VIEW my_view AS SELECT * FROM my_table
If you don’t want the query to return an error in case a view with the provided name already exists, include IF NOT EXISTS
:
CREATE VIEW IF NOT EXISTS my_view AS SELECT * FROM my_table
To replace an exisiting view, use OR REPLACE
:
CREATE OR REPLACE VIEW my_view AS SELECT * FROM my_other_table