v.23.9Improvement

clickhouse-local and clickhouse-client Enhance --query Parameter Support

clickhouse-local and clickhouse-client now allow to specify the --query parameter multiple times, e.g. ./clickhouse-client --query "SELECT 1" --query "SELECT 2". This syntax is slightly more intuitive than ./clickhouse-client --multiquery "SELECT 1;S ELECT 2", a bit easier to script (e.g. queries.push_back('--query "$q"')) and more consistent with the behavior of existing parameter --queries-file (e.g. ./clickhouse client --queries-file queries1.sql --queries-file queries2.sql). #54249 (Robert Schulze).
clickhouse-local and clickhouse-client now support specifying the --query parameter multiple times to execute multiple queries in one command.

Why it matters

This feature addresses the need for a more intuitive and script-friendly way to run multiple queries sequentially, improving upon the previous --multiquery option which combined queries into a single string. It also aligns command behavior with the existing --queries-file parameter, making scripting and automation simpler and more consistent.

How to use it

Users can run multiple queries by repeating the --query flag with different SQL statements, for example:

./clickhouse-client --query "SELECT 1" --query "SELECT 2"

This can also be used similarly in scripts by appending query strings individually with --query parameters.