Oracle uses the merge into statement to update data

Source: Internet
Author: User
Tags one table

/*merge into detailed introduction
The merge statement is a new syntax for merging the UPDATE and INSERT statements oracle9i.
With the merge statement, another table is queried based on the join criteria of one table or subquery,
The connection condition matches the execution insert on the update that cannot be matched.
This syntax only needs a full table scan to complete the whole work, the execution efficiency is higher than insert+update.
*/
/* Syntax:
MERGE [into [Schema.] table [T_alias]
USING [schema.] {Table | view | subquery} [T_alias]
On (condition)
When matched then Merge_update_clause
When isn't matched then merge_insert_clause;
*/

1MERGE intot_product T2 USING t_product_temp u3  on(u.id=t.id)4  whenMatched Then5     UPDATE  SETT.name=U.name,t.orderid=U.orderid,6T.descr=U.DESCR7      --Delete where u.id=18  when  notMatched Then 9     INSERT(ID, name, OrderID, DESCR)VALUES(U.id, U.name,u.orderid, U.DESCR)Ten --When not matched by U and t.id=u.id Then One   --Delete;

Features of the new feature, faster replication of table data performance, one-time read, can quickly copy data to the target table, where the DELETE statement is also supported in the update

You can filter some data that does not need to be updated. The speed is still very good.

Oracle uses the merge into statement to update data

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.