---- 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