UPDATE multiple tables in ORACLE

Source: Internet
Author: User

UPDATE multiple tables in Oracle
The following methods can be implemented:
One is:
Update table1
Set (field1, field2. ..) =
(Select Field1, field2 ....
From table2
Where table1.field1 = table2.field1)
Where table1.field1 in (select field1 from table2)

Two types are:
Associate fields table1 and table2 with the PRimary key or Union key.
Update (Select Table1.field1, table1.field2, table2.field1, table2.field2
From table1, table2
Where Table1.Field1 = table2.field1)

Set table1.table2 = table2.table2,
Table1.fieldn = table2.tablen,
......
For Field1 of table1 and field1 of table2, you must create a primary key or a unique index.

Three types are:
Merge into table1
Using table2
On (table1.field1 = table2.field1 and ....)
When matched then Update set table1.field2 = table2.field2,
Table1.fieldn = table2.fieldn,
......
When not matched then [doing other thing]

The cursor can be used for other methods.

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.