DB2 insert statement

Source: Internet
Author: User
Tags db2 insert

---- Start

Some SQL users write insert statements, but most people do not know that DB2's insert statements haveThree formats, That is:Insert a row at a time,Insert multiple rows at a time and insert them from select statements.Consider the following:

Create Table user <br/> (<br/> name varchar (20) not null, --- name <br/> birthday date --- birthday <br/> ); 

We want you to insert a row of data as follows:

Insert into user (name, birthday) values ('zhang san', '2017-1-1 '); 

We want you to insert three rows of data as follows:

Insert into user (name, birthday) values ('zhang san', '2014-1-1-1 '); <br/> insert into user (name, birthday) values ('Li si ', '2014-1-1 '); <br/> insert into user (name, birthday) values ('王', '2014-1-1 '); 

In addition, we can also write:

Insert into user (name, birthday) values <br/> ('zhang san', '2014-1-1 '), <br/> ('Li si ', '2014-1-1-1 '), <br/> ('王', '2014-1-1-1 '); 

So what are the advantages of the latter method? There are two benefits:

1. better performance.

2. Because of a statement, they are a processing unit, either inserted or not inserted.

 

In addition, we can also insert data from the SELECT statement in the following format:

Insert into user (name, birthday) <br/> select <column1>, <column2> from <table_name> where... 

The above is relatively simple. I will not give an example.

 

---For more information, see:DB2 SQL

----Statement: indicate the source for reprinting.

---- Last updated on 2009.11.5

---- Written by shangbo on 2009.9.24

---- End

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.