Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle merge merges data

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Features introduced by Oracle 9i

-- perform insert or update operations according to the specified conditions

-- perform an update operation if there is a row that meets the criteria; otherwise, perform an insert operation

-- 1 avoid repeatedly performing insert and delete operations

-- 2 improved efficiency and easy to use

-3 is often used in data warehouse applications

The columns of two tables can be different and not necessarily the same data structure.

The syntax is as follows

Here take the emp table as an example

Create table emp1 as select empno,ename,job,mgr from emp

Create table emp2 as select * from emp

Merge into emp2 e2

Using emp1 E1 on (e1.empno=e2.empno)

When matched then

Update set e2.enamestatione1.enamerecovere2.jobroome1.job

When not matched then

Insert (empno,ename,job) values (e1.empnoree1.enameree1.job)

Table 1: as long as there is a change in the data corresponding to the associated id, the data will be synchronized and the data will increase e2.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report