PL/SQL USE insert... Select Insert multiple rows at a time

Source: Internet
Author: User

We usually use the INSERT command to insert rows into the table. Sometimes, you need to add specific data to the target table based on the records of existing tables and views. This can be done using 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

In this way, a large amount of data is inserted into the target table at a time using the insert... select statement. Note the following points when using this statement:
The insert statement cannot select data from the inserted Table or view.

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.

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

Of course, there are still many ways to achieve this purpose. This article provides a solution to solve this kind of requirement, which is not necessarily the best. It is only for your reference ~

If you are an expert in this field, let us know about it ~

 

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.