码迷,mamicode.com
首页 > 数据库 > 详细

Oracle数据表之间的数据同步

时间:2014-09-12 15:04:03      阅读:349      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   for   数据   div   sp   log   

保证两个数据表结构相同,如不相同只能同步相同字段;

只是思路,具体请根据需求修改.

declare  
      
cursor csrn_mon
is          
select *       
from table2;           
row_mon csrn_mon%rowtype;

cursor csrn_loc
is
select * 
from table1;
row_loc csrn_loc%rowtype;

cursor csrn_del
is
select xh from table1 minus select xh from table2;
row_del csrn_del%rowtype;

cursor csrn_ins
is
select xh from table2 minus select xh from table1;
row_ins csrn_ins%rowtype;

begin       
     
for row_mon in csrn_mon loop           
    for row_loc in csrn_loc loop  
        if row_loc.xh = row_mon.xh then
           dbms_output.put_line(更新信息: || row_loc.xh);
        end if;
    end loop;
end loop;

for row_del in csrn_del loop
    dbms_output.put_line(删除信息: || row_del.xh);
end loop;

for row_ins in csrn_ins loop
    dbms_output.put_line(插入信息: || row_ins.xh);
end loop;

end;

Oracle数据表之间的数据同步

标签:style   blog   color   ar   for   数据   div   sp   log   

原文地址:http://www.cnblogs.com/Kconnie/p/3968310.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!