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;