mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 01:54:55 +00:00
1.6 KiB
1.6 KiB
slug | sidebar_position | sidebar_label | title |
---|---|---|---|
/en/sql-reference/table-functions/view | 210 | view | view |
Turns a subquery into a table. The function implements views (see CREATE VIEW). The resulting table does not store data, but only stores the specified SELECT
query. When reading from the table, ClickHouse executes the query and deletes all unnecessary columns from the result.
Syntax
view(subquery)
Arguments
subquery
—SELECT
query.
Returned value
- A table.
Example
Input table:
┌─id─┬─name─────┬─days─┐
│ 1 │ January │ 31 │
│ 2 │ February │ 29 │
│ 3 │ March │ 31 │
│ 4 │ April │ 30 │
└────┴──────────┴──────┘
Query:
SELECT * FROM view(SELECT name FROM months);
Result:
┌─name─────┐
│ January │
│ February │
│ March │
│ April │
└──────────┘
You can use the view
function as a parameter of the remote and cluster table functions:
SELECT * FROM remote(`127.0.0.1`, view(SELECT a, b, c FROM table_name));
SELECT * FROM cluster(`cluster_name`, view(SELECT a, b, c FROM table_name));
See Also