我的java天地

Oracle 快照及 dblink使用 (两台服务器数据同步)

--名词说明:源——被同步的数据库
--          目的——要同步到的数据库

/*一、创建dblink:*/
--1、在目的数据库上,创建dblin
drop public database link wc;
Create public
database link wc
Connect to test identified by xiongwei using 'toby';

select * from dba_db_links;

select * from a@wc;
--源数据库的用户名、密码、服务器名k


/*二、创建快照:*/
--1、在源和目的数据库上同时执行一下语句,创建要被同步的表
drop table tb_anson;
create table tb_anson(c1 varchar2(12));
alter table tb_anson add constraint pk_anson primary key (C1);

--2、在目的数据库上,测试dblink
select * from tb_anson@dblink_anson;
select * from tb_anson;

--3、在目的数据库上,创建要同步表的快照日志
Create snapshot log on tb_anson;

--4、创建快照,快照(被同步(源)数据库服务必须启动)
Create snapshot sn_anson as select * from tb_anson@dblink_anson;

--5、设置快照刷新时间
Alter snapshot anson  refresh fast Start with sysdate+1/24*60 next sysdate+10/24*60;
--oracle自动在1分钟后进行第一次快速刷新,以后每隔10分钟快速刷新一次
Alter snapshot anson  refresh complete Start with sysdate+30/24*60*60 next sysdate+1;
--oracle自动在30钞后进行第一次完全刷新,以后每隔1天完全刷新一次

--6、手动刷新快照
begin
dbms_refresh.refresh('"CS"."SN_ANSON"');
end;

eg:
drop public database link dblink_e3nfjj;
Create public
database link dblink_e3nfjj
Connect to e3nfjj identified by e3nfjj using 'ORCL10_192.168.20.26';

create table template as
select * from template@dblink_e3nfjj;


本用户登录进去的一定要能连接 'ORCL10_192.168.20.26' 这个Oracle 的SID.

posted on 2009-04-09 21:23 tobyxiong 阅读(474) 评论(0)  编辑  收藏 所属分类: DATABASES


只有注册用户登录后才能发表评论。


网站导航:
 
<2009年4月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

导航

统计

常用链接

留言簿(3)

随笔分类(144)

随笔档案(157)

相册

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜