ClickHouse Bulk Insert Guide: Fast Data Loading
In ClickHouse, batch data can be written using the INSERT statement. Here is a simple example:
INSERT INTO test_table (col1, col2, col3) VALUES ('value1', 'value2', 'value3'), ('value4', 'value5', 'value6'), ('value7', 'value8', 'value9');
In the example above, test_table is the name of the table where data is to be inserted, col1, col2, and col3 are the column names in the table, and the values following them are the data to be inserted. Multiple rows of data can be inserted at once.
If you need to insert a large amount of data in bulk, you can also use the INSERT SELECT statement to select data from another table and insert it into the target table. An example is shown below:
INSERT INTO test_table (col1, col2, col3) SELECT col1, col2, col3 FROM source_table WHERE condition;
In the example above, source_table is the table from which data is selected, condition is the filter condition, and the SELECT statement is used to choose data and insert it into the target table.
It is important to note that in ClickHouse, batch data insertion can be used to improve performance and efficiency. By using batch insertion, a large amount of data can be inserted at once, reducing the number of insertion operations and therefore enhancing performance.