oracle資料庫snap的設定

fengzhengsheng發表於2009-02-21
snap用於從一個資料庫中提取一張或多張表的到本地資料庫,操作如下:[@more@]

--名詞說明:源——被同步的資料庫
-- 目的——要同步到的資料庫

/*一、建立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);

--2、在目的資料庫上,測試dblink
select * from ;
select * from big_table;

--3、在源資料庫上,建立要同步表的快照日誌
create snapshot log on big_table;

--4、建立快照,快照(被同步(源)資料庫服務必須啟動)
create snapshot big as select * from ;

--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"."big"');
end;


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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18976069/viewspace-1017686/,如需轉載,請註明出處,否則將追究法律責任。

相關文章