Snap is used to extract one or more tables from a database to the local database. The operations are as follows:
-- Glossary: Source-database to be synchronized
-- Purpose -- database to be synchronized
/* 1. Create a dblink :*/
-- 1. Create dblink on the target database
Drop database link rac;
Create public
Database link rac connect to fzs identified by ljkj using 'vm ';
-- The username, password, and server name of the source database. The rac here is the database connection name for future access. The vm is the string used to connect to the source database.
/* 2. Create a snapshot :*/
-- 1. Execute the statement on both the source and target databases to create the table to be synchronized.
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. Test on the target database
Dblink select * from big_table @ rac;
Select * from big_table; select * from big_table @ rac;
Select * from big_table;
-- 3. Create a snapshot log for the table to be synchronized in the source database
Create snapshot log on big_table;
Create snapshot log on big_table;
-- 4. Create a snapshot. the snapshot must be started when the Database Service is synchronized (source)
Create snapshot big as select * from big_table @ rac;
Create snapshot big as select * from big_table @ rac;
-- 5. Set the snapshot refresh time
Alter snapshot anson refresh fast Start with sysdate + 1/24*60 next sysdate + 10/24*60;
-- Oracle automatically performs the first quick refresh in 1 minute, and then refresh every 10 minutes.
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 automatically performs the first full refresh after 30 banknote, and then completely refresh every other day
-- 6. manually refresh the snapshot
Begin dbms_refresh.refresh ('"CS". "big "');
End; begin dbms_refresh.refresh ('"FZS". "BIG "');
End;