Oracle数据库同步

laoqi1999 2009-08-17 05:52:55
大家好!

现在有2个数据库,需要同步另外一个公司的数据库里的数据,他们是以视图的方式开发给我的。只有select权限。同步实时性要求不高,一天一次。

请问,有什么办法,可以实现同步,前提是除了select外,不操作对方的数据库。

谢谢!
...全文
142 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
laoqi1999 2009-08-21
  • 打赏
  • 举报
回复
谢谢,去试试
inthirties 2009-08-17
  • 打赏
  • 举报
回复
同意上面的方法。
Dave 2009-08-17
  • 打赏
  • 举报
回复
1. 先在A库上做B库的DB_LINK

2. 再在A库上 用merge into 同步两张表
merge into 解决用B表跟新A表数据,如果A表中没有,则把B表的数据插入A表;

语法:

MERGE INTO [your table-name] [rename your table here]

USING ( [write your query here] )[rename your query-sql and using just like a table]

ON ([conditional expression here] AND [...]...)

WHEN MATHED THEN [here you can execute some update sql or something else ]

WHEN NOT MATHED THEN [execute something else here ! ]

-------实例-------

merge into a
using (select id,name from b ) c
on(a.id=c.id )
when matched then update set a.name=c.name
when not matched then insert (a.id,a.name) values (c.id,c.name);

3. 把这个SQL 写成脚本,放到crontab里,或者写成存储过程,定时执行

17,091

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧