Clickhouse-client命令行客户端支持多行SQL输入

Clickhouse-client是Clickhouse自带的命令行客户端,其默认是认定每行一个SQL语句,如果希望多行输入,需要启动时指定-m参数,然后使用分号作为语句结束的标志。

参考

样例

执行如下的SQL,分成2行

select
version();

默认

换行算一条语句,会报2个错误

localhost :) select

Syntax error: failed at position 7 (end of query):

select

Expected one of: 。。。。。。。。。。。。。。, TOP

localhost :) version();

Syntax error: failed at position 1 ('version'):

version();

Expected one of: 。。。。。。。。。。。。。。y

localhost :)

采用多行模式

启动clickhouse-client时指定-m参数即可。

[root@localhost ~]# clickhouse-client -m
ClickHouse client version 21.4.5.46 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 21.4.5 revision 54447.

localhost :) select
:-] version();

SELECT version()

Query id: 66381475-eb42-42d7-9b80-1a6d97e49ddb

┌─version()─┐
│ 21.4.5.46 │
└───────────┘

1 rows in set. Elapsed: 0.004 sec.

localhost :)