3

Alternative in ClickHouse Select query to pretty print like in MySQL vertically.

For example -

SELECT * from table \g;

I found this resource but its just text https://clickhouse-docs.readthedocs.io/en/latest/formats/vertical.html

With --multiline as a parameter for clickhouse-client I am getting following error . Though i can use \G format as per one of the answer without this param :

 :) 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 ;
Divyanshu Jimmy
  • 2,542
  • 5
  • 32
  • 48

2 Answers2

10

ClickHouse supports this feature:

You can specify \G instead of or after the semicolon. This indicates Vertical format.

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
*/
vladimir
  • 13,428
  • 2
  • 44
  • 70
  • 1
    Thanks for sharing, i am using click house-client with --multiline parameter and in that case its not working. However it works without --multiline argument.Edited my question with details – Divyanshu Jimmy May 29 '20 at 12:00
6

Well, it was quick. I have to use FORMAT Parameter :

select * from hits_v1  limit 100  FORMAT Vertical;

More to study here : https://clickhouse.tech/docs/en/interfaces/formats/

vladimir
  • 13,428
  • 2
  • 44
  • 70
Divyanshu Jimmy
  • 2,542
  • 5
  • 32
  • 48