Help Center/
CloudTable Service/
Developer Guide/
ClickHouse Application Development Guide/
Data Migration and Synchronization/
Importing and Exporting data
Updated on 2024-11-28 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 ClickHouse.
Importing and Exporting Data in CSV Format
- Import data in CSV format.
- For normal clusters:
cat csv_ssl | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 --query="INSERT INTO test145 FORMAT CSV"
- For security clusters:
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"
- For normal clusters:
- 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 created during cluster creation.
- INSERT INTO: Enter the target data table behind this parameter.
- cat File path: indicates the file storage path, which can be customized.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
- Export data in CSV format.
- For normal clusters:
./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
- For security clusters:
./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
- For normal clusters:
- 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 created during cluster creation.
- SELECT * FROM: Enter the target data table behind this parameter.
- ./csv_no_ssl: indicates the file storage path, which can be customized.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
Importing and Exporting Data in Parquet Format
- Import data in Parquet format.
- For normal clusters:
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"
- For security clusters:
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"
- For normal clusters:
- parquet_no_ssl.parquet: indicates the path for storing the files, which can be customized.
- 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 created during cluster creation.
- INSERT INTO: Enter the target data table behind this parameter.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
- Export data in Parquet format.
- For normal clusters:
./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
- For security clusters:
./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
- For normal clusters:
- 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 created during cluster creation.
- select * from: Enter the target data table behind this parameter.
- ./parquet_no_ssl.parquet: indicates the path for storing the exported Parquet files, which can be customized.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
Importing and Exporting Data in ORC Format
- Import data in ORC format.
- For normal clusters:
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"
- For security clusters:
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
- For normal clusters:
- cat orc_no_ssl.orc: path for storing the ORC files, which can be customized.
- 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 created during cluster creation.
- INSERT INTO: Enter the target data table behind this parameter.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
- Export data in ORC format.
- For security clusters:
./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
- For normal clusters:
./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
- For security clusters:
- 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 created during cluster creation.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
- select * from: Enter the target data table behind this parameter.
- /opt/student.orc: path for storing the exported ORC file, which can be customized.
Importing and Exporting Data in JSON Format
- Import data in JSON format.
- For normal clusters:
cat ./jsonnossl.json | ./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 --query="INSERT INTO test141 FORMAT JSON"
- For security clusters:
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"
- For normal clusters:
- cat File path: indicates the source path, which can be customized.
- 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 created during cluster creation.
- INSERT INTO: Enter the target data table behind this parameter.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
- Export data in JSON format.
- For security clusters:
./clickhouse client --host 192.168.x.x --port port --user admin --password password --database test010 -m --query="select * from test139 FORMAT JSON" > ./jsonnossl.json
- For normal clusters:
./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
- For security clusters:
- 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 created during cluster creation.
- SELECT * FROM: Enter the target data table behind this parameter.
- ./jsonssl.json: indicates the destination path, which can be customized.
- config-file ./config.xml: specifies the configuration file. For details, see Configuring Secure Channel Encryption for ClickHouse Clusters.
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