Merge into Oracle's Saveoruapdate

Source: Internet
Author: User

1. Initial data:

Sql> select * from A; ID                     NAME--------------------------------------------1                      1sql> select * from B; ID                     NAME--------------------------------------------1                      211                     11

2, Target: 1) The ID in table A is the same as the ID in B table, the update a.name to b.name; 2) the ID in table B is not in a table, copy the records of B table, insert into a table

3. Function Realization:

Merge into a A with B b on (a.id = b.id)--on is the match condition when matched then--Update a.nameupdate Set a.name = b.name where 1=1 when matching-- Here you can add the where condition when not matched then--copy and insert Binsert values (b.id,b.name) where 1=1

  

Merge into Oracle's Saveoruapdate

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.