Help Center/CloudTable Service/User Guide/Using ClickHouse/Common SQL Commands for Storage-Compute Coupled ClickHouse/SELECT
Updated on 2025-12-29 GMT+08:00
SELECT
This section describes how to execute a SELECT statement to query data.
Basic Syntax
SELECT [DISTINCT] expr_list [FROM [database_name.]table | (subquery) | table_function] [FINAL] [SAMPLE sample_coeff] [ARRAY JOIN ...] [GLOBAL] [ANY|ALL|ASOF] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER|SEMI|ANTI] JOIN (subquery)|table (ON <expr_list>)|(USING <column_list>) [PREWHERE expr] [WHERE expr] [GROUP BY expr_list] [WITH TOTALS] [HAVING expr] [ORDER BY expr_list] [WITH FILL] [FROM expr] [TO expr] [STEP expr] [LIMIT [offset_value, ]n BY columns] [LIMIT [n, ]m] [WITH TIES] [UNION ALL ...] [INTO OUTFILE filename] [FORMAT format]
Example:
- View the ClickHouse cluster information.
select * from system.clusters;
- View the macros set for the node.
select * from system.macros;
- Check the database capacity.
select sum(rows) as "Total number of rows", formatReadableSize(sum(data_uncompressed_bytes)) as "Original size", formatReadableSize(sum(data_compressed_bytes)) as "Compression size", round(sum(data_compressed_bytes) / sum(data_uncompressed_bytes) * 100, 0) "Compression rate" from system.parts;
- Query the capacity of the test table. Add and modify the WHERE clause as required.
select sum(rows) as "Total number of rows", formatReadableSize(sum(data_uncompressed_bytes)) as "Original size", formatReadableSize(sum(data_compressed_bytes)) as "Compression size", round(sum(data_compressed_bytes) / sum(data_uncompressed_bytes) * 100, 0) "Compression rate" from system.parts where table in ('test') and partition like '2020-11-%' group by table;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.

