INSERT INTO
This section describes how to insert data.
Basic Syntax
- Insert data in standard format.
INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
For columns that exist in the table structure but not in the list to be inserted, data is filled as follows:
- If the DEFAULT expression is defined, the value is calculated according to the DEFAULT expression.
- If no DEFAULT expression is defined, the value is filled with zero or an empty string.
Insert data by referring to Creating a Table by Copying the Structure of an Existing Table.
insert into demo_t values(1,'Candy','23','M'),(2,'cici','33','F');
- Insert data using the SELECT result.
INSERT INTO [db.]table [(c1, c2, c3)] SELECT ...
The columns to insert data are mapped to the columns in the SELECT statement based on their positions. The columns can have different names in the SELECT statement and in the INSERT statement. The system converts the data types of the columns.
Except for the VALUES type, all other data types do not support expressions such as now() and 1+2. The VALUES type allows you to use these expressions to a limited extent. However, you are not advised doing so because executing these expressions is inefficient.
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.
For any further questions, feel free to contact us through the chatbot.
Chatbot