About Oracle Update multiple table problems

Source: Internet
Author: User

About Oracle Update multiple table problems
There are several ways to achieve this:
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 kinds are:
Create a primary key primary key or union key for the table1,table2 associated field
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,
......
Table1 's Field1 and table2 Field1 will need to establish a primary key or a unique index.

Three kinds 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 isn't matched then [doing other thing]

The remaining methods can use cursors

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.