PL/SQL INSERT multiple rows of data at a time using INSERT... SELECT

Source: Internet
Author: User

PL/SQL USE INSERT... to INSERT multiple rows in a SELECT statement, we usually use the INSERT command to INSERT rows into a table. Sometimes, you need to add specific data to the target table based on the records of existing tables and views, you can use INSERT... SELECT statement. The statement actually contains two parts: INSERT (INSERT statement) and SELECT (query statement). Its syntax can be expressed as follows:
Insert into Table2 (field1, field2,...) select value1, value2,... from Table1, INSERT a large amount of data into the target table at a time using the Insert... SELECT statement. Note the following points when using this statement: the INSERT statement www.2cto.com cannot select data from the table or view being inserted. In the insert into statement, the number of columns must be equal to the number of columns returned from the SELECT statement. In the insert into statement, the Data Type of the column must be the same as that of the column returned by the SELECT statement.
The syntax for the same effect in the T-SQL is as follows: SELECT vale1, value2 into Table2 from Table1. INSERT... SELECT statements are usually used to create a search table, which improves the search performance. A query table can contain data distributed in multiple tables of multiple databases. Because the connection between multiple tables is slower than that of simple tayun, executing SELECT query on a table is much faster than executing a long and complex connection query. Www.2cto.com is working on the outpatient doctor's site project today. You just need to copy some rows from other tables to another table and write down this article. This method is feasible and efficient, as evidenced by the following:
Author: DebugLZQ

Related Article

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.