After this PR #9272, the `docs/build_help_zip.sh` will run failed. This PR fix this issue. But the help module still has some parse problem, I will fix it in next PR. This CL mainly changes: 1. fix `docs/build_help_zip.sh` error 2. remove `sql-reference-v2` to `sql-reference` 3. modify build extension github action to run `docs/build_help_zip.sh`
4.4 KiB
title, language
| title | language |
|---|---|
| INSERT | en |
INSERT
Name
INSERT
Description
The change statement is to complete the data insertion operation.
INSERT INTO table_name
[ PARTITION (p1, ...) ]
[ WITH LABEL label]
[ (column [, ...]) ]
[ [ hint [, ...] ] ]
{ VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }
Parameters
tablet_name: The destination table for importing data. Can be of the form
db_name.table_namepartitions: Specify the partitions to be imported, which must be partitions that exist in
table_name. Multiple partition names are separated by commaslabel: specify a label for the Insert task
column_name: The specified destination column, must be a column that exists in
table_nameexpression: the corresponding expression that needs to be assigned to a column
DEFAULT: let the corresponding column use the default value
query: a common query, the result of the query will be written to the target
hint: some indicator used to indicate the execution behavior of
INSERT. Bothstreamingand the default non-streamingmethod use synchronous mode to completeINSERTstatement execution The non-streamingmethod will return a label after the execution is completed, which is convenient for users to query the import status throughSHOW LOAD
Notice:
When executing the INSERT statement, the default behavior is to filter the data that does not conform to the target table format, such as the string is too long. However, for business scenarios that require data not to be filtered, you can set the session variable enable_insert_strict to true to ensure that INSERT will not be executed successfully when data is filtered out.
Example
The test table contains two columns c1, c2.
- Import a row of data into the
testtable
INSERT INTO test VALUES (1, 2);
INSERT INTO test (c1, c2) VALUES (1, 2);
INSERT INTO test (c1, c2) VALUES (1, DEFAULT);
INSERT INTO test (c1) VALUES (1);
The first and second statements have the same effect. When no target column is specified, the column order in the table is used as the default target column.
The third and fourth statements express the same meaning, use the default value of the c2 column to complete the data import.
- Import multiple rows of data into the
testtable at one time
INSERT INTO test VALUES (1, 2), (3, 2 + 2);
INSERT INTO test (c1, c2) VALUES (1, 2), (3, 2 * 2);
INSERT INTO test (c1) VALUES (1), (3);
INSERT INTO test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT);
The first and second statements have the same effect, import two pieces of data into the test table at one time
The effect of the third and fourth statements is known, and the default value of the c2 column is used to import two pieces of data into the test table
- Import a query result into the
testtable
INSERT INTO test SELECT * FROM test2;
INSERT INTO test (c1, c2) SELECT * from test2;
- Import a query result into the
testtable, specifying the partition and label
INSERT INTO test PARTITION(p1, p2) WITH LABEL `label1` SELECT * FROM test2;
INSERT INTO test WITH LABEL `label1` (c1, c2) SELECT * from test2;
Asynchronous import is actually a synchronous import encapsulated into asynchronous. Filling in streaming and not filling in execution efficiency is the same.
Since the previous import methods of Doris are all asynchronous import methods, in order to be compatible with the old usage habits, the INSERT statement without streaming will still return a label. Users need to view the label import job through the SHOW LOAD command. state.
Keywords
INSERT