Doris Batch Data Insertion (Using INSERT INTO and LOAD DATA Statements)
= =
Introduction
Batch inserting data is a key feature in Doris, used to quickly insert multiple records into a table. This method is faster than inserting one by one and can significantly improve data insertion efficiency.
What is LOAD DATA
LOAD DATA is a method in Doris to load data from files or network resources and insert it into a table. It supports multiple delimiters and quoting schemes.
INSERT INTO Statement
INSERT INTO is a standard SQL statement used to insert data into a table.
Syntax
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...)
Example
INSERT INTO customers (name, email)
VALUES ('John Doe', 'john@example.com')
LOAD DATA Statement
LOAD DATA is a statement unique to Doris, used for quickly inserting data.
Syntax
LOAD DATA FROM 'path'
OPTION (DELIMITER '[', QUOTECHAR '"', ESCAPE '\\\\')
INTO TABLE table_name
(column1, column2, ...)
Example
LOAD DATA FROM '/data/customers.csv'
OPTION (DELIMITER ',')
INTO TABLE customers
(name, email)
Comparison of INSERT INTO and LOAD DATA
| | INSERT INTO | LOAD DATA |
| --- | --- | --- |
| Speed | Slow | Fast |
| Scalability | low | high |
Application Scenarios
1. When inserting large amounts of data, use LOAD DATA to quickly insert data.
2. When loading data from files or network resources and inserting it into a table, use LOAD DATA.
Conclusion
Batch inserting data is an important feature in Doris, which can be implemented through INSERT INTO and LOAD DATA statements. Choosing the appropriate method can improve data insertion efficiency and scalability.