Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to insert multiple values in oracle with one statement

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report