有没有办法在 ClickHouse 中漂亮地打印 SELECT 查询结果?

Div*_*mmy 4 clickhouse

ClickHouse Select 查询中的替代方案可以像 MySQL 中那样垂直打印。

例如 -

SELECT * from table \g;
Run Code Online (Sandbox Code Playgroud)

我找到了这个资源,但它只是文本 https://clickhouse-docs.readthedocs.io/en/latest/formats/vertical.html

使用 --multiline 作为 clickhouse-client 的参数,我收到以下错误。虽然我可以根据答案之一使用 \G 格式,但无需此参数:

 :) select * from hits_v1 limit 2; \G
:-] ;

Syntax error (Multi-statements are not allowed): failed at position 30 (end of query):

select * from hits_v1 limit 2; \G ;
Run Code Online (Sandbox Code Playgroud)

vla*_*mir 10

ClickHouse 支持此功能

\n\n
\n

您可以指定 \\G 来代替分号或在分号之后指定。这表示垂直格式。

\n
\n\n
select * from numbers(2)\\G\n/* result\nRow 1:\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\nnumber: 0\n\nRow 2:\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\nnumber: 1\n*/\n
Run Code Online (Sandbox Code Playgroud)\n\n
select * from numbers(2);\\G\n/* result\nRow 1:\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\nnumber: 0\n\nRow 2:\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\nnumber: 1\n*/\n
Run Code Online (Sandbox Code Playgroud)\n


Div*_*mmy 7

嗯,很快。我必须使用 FORMAT 参数:

select * from hits_v1  limit 100  FORMAT Vertical;
Run Code Online (Sandbox Code Playgroud)

更多需要学习的内容: https: //clickhouse.tech/docs/en/interfaces/formats/