Help Center/
CloudTable Service/
User Guide/
Using ClickHouse/
Data Migration and Synchronization/
Importing and Exporting data
Updated on 2025-07-24 GMT+08:00
Importing and Exporting data
This section describes the basic syntax and usage of the SQL statements for importing and exporting file data using the ClickHouse client.
Importing and Exporting Data in CSV Format
- Import data in CSV format.
- Non-security cluster
cat csv_ssl | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 --query="INSERT INTO test145 FORMAT CSV"
- Security cluster
cat csv_no_ssl | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 --query="INSERT INTO test146 FORMAT CSV"
- Non-security cluster
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- INSERT INTO: indicates the target data table.
- cat File path: indicates the user-defined path for storing the file.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
- Export data in CSV format.
- Non-security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password Password --database test010 -m --query="select * from test139 FORMAT CSV" > ./csv_no_ssl
- Security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 -m --query="select * from test139 FORMAT CSV" > ./csv_no_ssl
- Non-security cluster
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- SELECT * FROM: indicates the target data table.
- ./csv_no_ssl: indicates the user-defined path for storing the file.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
Importing and Exporting Data in Parquet Format
- Import data in Parquet format.
- Non-security cluster
cat parquet_no_ssl.parquet | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 --query="INSERT INTO test145 FORMAT Parquet"
- Security cluster
cat parquet_no_ssl.parquet | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 --query="INSERT INTO test146 FORMAT Parquet"
- Non-security cluster
- parquet_no_ssl.parquet: indicates the user-defined path for storing the file.
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- INSERT INTO: indicates the target data table.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
- Export data in Parquet format.
- Non-security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 -m --query="select * from test139 FORMAT Parquet" > ./parquet_no_ssl.parquet
- Security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 -m --query="select * from test139 FORMAT Parquet" > ./parquet_ssl.parque
- Non-security cluster
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- select * from: indicates the target data table.
- ./parquet_no_ssl.parquet: indicates the user-defined path for storing the file.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
Importing and Exporting Data in ORC Format
- Import data in ORC format.
- Non-security cluster
cat orc_no_ssl.orc | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 --query="INSERT INTO test143 FORMAT ORC"
- Security cluster
cat orc_no_ssl.orc | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 --query="INSERT INTO test144 FORMAT ORC
- Non-security cluster
- cat orc_no_ssl.orc: indicates the user-defined path for storing the file.
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- INSERT INTO: indicates the target data table.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
- Export data in ORC format.
- Security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 -m --query="select * from test139 FORMAT ORC" > ./orc_ssl.orc
- Non-security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 -m --query="select * from test139 FORMAT ORC" > ./orc_no_ssl.orc
- Security cluster
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
- select * from: indicates the target data table.
- /opt/student.orc: indicates the user-defined path for storing the file.
Importing and Exporting Data in JSON Format
- Import data in JSON format.
- Non-security cluster
cat ./jsonnossl.json | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 --query="INSERT INTO test141 FORMAT JSON"
- Security cluster
cat ./jsonssl.json | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 --query="INSERT INTO test142 FORMAT JSON"
- Non-security cluster
- cat File path: indicates the user-defined path for storing the file.
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- INSERT INTO: indicates the target data table.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
- Export data in JSON format.
- Security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 -m --query="select * from test139 FORMAT JSON" > ./jsonnossl.json
- Non-security cluster
./clickhouse client --host 192.168.x.x --port port --user admin --password password --config-file ./config.xml --database test010 -m --query="select * from test139 FORMAT JSON" > ./jsonssl.json
- Security cluster
- host: indicates the host name or ClickHouse instance IP address.
- port: indicates the port number (available on the cluster details page).
- user: indicates the username created during cluster creation.
- database: indicates the database name.
- password: indicates the password specified during cluster creation.
- SELECT * FROM: indicates the target data table.
- ./jsonssl.json: indicates the user-defined path for storing the file.
- config-file ./config.xml: indicates the configuration file. For details, see Using a Client to Connect to a ClickHouse Security Cluster.
Parent topic: Data Migration and Synchronization
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot