Get the App
SLTechnology News&Howtos  ›  Database  › 

How to insert multiple values in oracle with one statement

Shulou Source: shulou.com Published: 2022-05-31 22:33:17 09月29日 Update

How to insert multiple values in oracle with one statement? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

When I want to insert multiple pieces of data into the database, I use the following statement:

Insert into Table 1 (Field 1, Field 2) values (1), (2), (3), (3)

There is nothing wrong with the syntax if this statement is executed in mysql, but there is always an error when executed on oracle:

ORA-00933: the SQL command did not end correctly

Then came the following solution:

/ *-- 1. Create table create or replace table pm_ci (ci_id varchar2 (20) not null,stu_ids varchar2); create table pm_stu (stu_id varchar2 (20) not null,stu_name varchar2);-insert data insert into pm_ci values ('1Ye Ji Ji' 1'); insert into pm_ci values ('2'Li Jing 1'); insert into pm_stu (stu_id,stu_name) values') Oracle insert multiple values method:-- personally experimented with oracle does not support the use of insert into Table 1 (Field 1, Field 2) values (1Mague 2), (2jing3), (3Pie4); this statement inserts multiple databases, but mysql supports it, so how to insert multiple values in one statement on oracle? My test sentence is as follows: insert all into pm_stu (stu_id, stu_name) values ('3Qing,' Wang Wu') into pm_stu values ('4Qing,' Zhao Liu') select 1 from dual The benefits of writing like this are summarized as follows, avoiding writing complex and unnecessary stored procedures, and avoiding the overhead of executing multiple SQL statements to connect to the database for many times. As for other benefits, if you have different opinions, please feel free to leave a comment and discuss. * / is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Statements data multiple fields databases support multiple benefits help Zhongtong different complex clear necessary content methods commands this overhead articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Xiaomi Shulou Tech Info Docker