[Oracle] The difference between the INSERT INTO SELECT statement and the SELECT INTO FROM statement

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Sweet Potato Yao June 25, 2016 14:34:47 

http://fanshuyao.iteye.com/

 

1. INSERT INTO SELECT statement

The sentence form is:

Insert into Table2(field1,field2,...) select value1,value2,... from Table1

 

Notice:

1. It is required that the target table Table2 must exist, and the fields field, field2... must also exist

2. Pay attention to the primary key constraint of Table2. If Table2 has a primary key and is not empty, then field1, field2... must include the primary key

3. Pay attention to the syntax, do not add values, and mix it with the sql that inserts a piece of data, do not write it as:

Insert into Table2(field1,field2,...) values (select value1,value2,... from Table1)

 

2. SELECT INTO FROM statement

The sentence form is:

SELECT vale1, value2 into Table2 from Table1

 

Notice:

1. It is required that the target table Table2 does not exist, because the table Table2 will be automatically created when inserting, and the specified field data in Table1 will be copied to Table2.

 

 

 

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Sweet Potato Yao June 25, 2016 14:34:47 

http://fanshuyao.iteye.com/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326941669&siteId=291194637