【问题标题】:Is there a way to pretty print SELECT query result in ClickHouse?有没有办法在 ClickHouse 中漂亮地打印 SELECT 查询结果?
【发布时间】:2020-09-16 16:47:15
【问题描述】:

ClickHouse 中的替代选择查询以像 MySQL 中那样垂直打印。

例如——

SELECT * from table \g;

我找到了这个资源,但它只是文本 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 ;

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    ClickHouse 支持this feature:

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

    select * from numbers(2)\G
    /* result
    Row 1:
    ──────
    number: 0
    
    Row 2:
    ──────
    number: 1
    */
    
    select * from numbers(2);\G
    /* result
    Row 1:
    ──────
    number: 0
    
    Row 2:
    ──────
    number: 1
    */
    

    【讨论】:

    • 感谢分享,我正在使用带有 --multiline 参数的 click house-client,在这种情况下它不起作用。但是它在没有 --multiline 参数的情况下工作。用详细信息编辑了我的问题
    【解决方案2】:

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

    select * from hits_v1  limit 100  FORMAT Vertical;
    

    在这里学习更多: https://clickhouse.tech/docs/en/interfaces/formats/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-29
      • 1970-01-01
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 2015-12-07
      相关资源
      最近更新 更多