Get the App
SLTechnology News&Howtos  ›  Database  › 

Oracle insert all compound table insertion

Shulou Source: shulou.com Published: 2022-06-01 12:39:13 09月16日 Update

Insert all (composite table insertion) is the function of inserting a query result into multiple tables at the same time. The advantage of using insert all is that multiple target tables can be inserted by reading the source table once, reducing the overhead of repeated reads.

Syntax:

INSERT [ALL] [conditional_insert_clause]

[insert_into_clause value_clause] (subquery)

Conditional_insert_clause is:

[ALL] [FIRST]

[WHEN condition THEN] [insert_into_clause value_clause]

[ELSE] [insert_into_clause value_clause]

All: regardless of priority, insert all of them as long as the conditions are met

First: consider the priority relationship. If there is data that satisfies the first when condition and the second when condition, the first then insert statement is executed and the second then does not insert the data already inserted by the first then.

The difference can also be described as that all may insert repeatedly as long as it meets the conditions, while first must first meet the conditions, then filter and do not repeat insertion.

Example:

Insert all when c1

Tags: Condition statement clause sequence data function simultaneously multiple multiple benefit cost goal example result syntax later face-to-face query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker Redmi NVidia Linux