ClickHouse cannot copy and paste multi-line commands

Problem background

[root@kubesphere3 ~]# docker run -it -p 8888:8888 yandex/tutorial-catboost-clickhouse
catboost@c17cb7190cc1:~$ clickhouse client
ClickHouse client version 19.15.2.2 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 19.15.2 revision 54426.

c17cb7190cc1 :) CREATE TABLE amazon_train

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

CREATE TABLE amazon_train 

Expected one of: ON, ENGINE, AS, token, OpeningRoundBracket, Dot, storage definition

c17cb7190cc1 :) exit
Bye.

When pasting a table-building command with line breaks, each line break will be treated as a statement, causing execution failure

solution

Add a -m parameter when entering ClickHouse client, after copying the statement, add a semicolon to indicate the end

catboost@c17cb7190cc1:~$ clickhouse client -m
ClickHouse client version 19.15.2.2 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 19.15.2 revision 54426.

c17cb7190cc1 :) CREATE TABLE amazon_train
:-] (
:-]     date Date MATERIALIZED today(),
:-]     ACTION UInt8,
:-]     RESOURCE UInt32,
:-]     MGR_ID UInt32,
:-]     ROLE_ROLLUP_1 UInt32,
:-]     ROLE_ROLLUP_2 UInt32,
:-]     ROLE_DEPTNAME UInt32,
:-]     ROLE_TITLE UInt32,
:-]     ROLE_FAMILY_DESC UInt32,
:-]     ROLE_FAMILY UInt32,
:-]     ROLE_CODE UInt32
:-] )
:-] ENGINE = MergeTree ORDER BY date;

CREATE TABLE amazon_train
(
    `date` Date MATERIALIZED today(), 
    `ACTION` UInt8, 
    `RESOURCE` UInt32, 
    `MGR_ID` UInt32, 
    `ROLE_ROLLUP_1` UInt32, 
    `ROLE_ROLLUP_2` UInt32, 
    `ROLE_DEPTNAME` UInt32, 
    `ROLE_TITLE` UInt32, 
    `ROLE_FAMILY_DESC` UInt32, 
    `ROLE_FAMILY` UInt32, 
    `ROLE_CODE` UInt32
)
ENGINE = MergeTree
ORDER BY date

Ok.

0 rows in set. Elapsed: 0.012 sec. 

Guess you like

Origin blog.csdn.net/wenyichuan/article/details/112538130