Oracle数据库snap的设置


snap用于从一个数据库中提取一张或多张表的到本地数据库,操作如下:

——名词说明:源——被同步的数据库

—— 目的——要同步到的数据库

 /*一、创建dblink:*/

 ——1、在目的数据库上,创建dblink

 drop database link rac;

create public

 database link rac connect to fzs identified by ljkj using 'vm';

——源数据库的用户名、密码、服务器名,这里的rac是数据库连接名,用于以后的访问,vm为连接源数据库的字符串。

 /*二、创建快照:*/

——1、在源和目的数据库上同时执行一下语句,创建要被同步的表

 create table big_table(c1 varchar2(12));

alter table big_table add constraint pk_big_table primary key (C1);

create table big_table(c1 varchar2(12));alter table big_table add constraint pk_big_table primary key (C1);

 ——2、在目的数据库上,测试

dblink select * from big_table@rac;

select * from big_table; select * from big_table@rac;

select * from big_table;

 ——3、在源数据库上,创建要同步表的快照日志

 create snapshot log on big_table;

create snapshot log on big_table;

 ——4、创建快照,快照(被同步(源)数据库服务必须启动)

create snapshot big as select * from big_table@rac;

create snapshot big as select * from big_table@rac;

——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;

Alter snapshot anson refresh complete Start with sysdate+30/24*60*60 next sysdate+1;

 ——oracle自动在30钞后进行第一次完全刷新,以后每隔1天完全刷新一次

——6、手动刷新快照

begin dbms_refresh.refresh('"CS"."big"');

end; begin dbms_refresh.refresh('"FZS"."BIG"');

end;

相关内容