Oracle8i Replication Management API Reference Release 2 (8.1.6) A76958-01 |
|
Create Snapshot Group, 3 of 3
/************************************************************************* STEP 1: CREATE SNAPSHOT LOGS AT MASTER SITE See the CREATE SNAPSHOT LOG in the Oracle8i SQL Reference for detailed information about this SQL statement. *************************************************************************/ --If you want one of your master sites to support a snapshot site, then --you need to create snapshot logs for each master table that is --replicated to a snapshot. Recall from Figure 2-1 that --ORC1.WORLD serves as the target master site for the SNAP1.WORLD --snapshot site. The required snapshot logs must be created at ORC1.WORLD. CONNECT scott/tiger@orc1.world CREATE SNAPSHOT LOG ON scott.emp; CREATE SNAPSHOT LOG ON scott.dept; CREATE SNAPSHOT LOG ON scott.bonus; CREATE SNAPSHOT LOG ON scott.salgrade; /************************************************************************* STEP 2: CREATE REPLICATED SCHEMA AND LINKS *************************************************************************/ --Before you begin building your snapshot group, you must make sure that --the replicated schema exists at the remote snapshot site and that the --necessary database links have been created. CONNECT system/manager@snap1.world CREATE USER scott IDENTIFIED BY tiger; GRANT connect, resource TO scott; CONNECT scott/tiger@snap1.world --The owner of the snapshots needs a database link pointing to the --proxy_refresher that was created when the snapshot site was set up; see --"CREATE MASTER SITE USERS" for information. CREATE DATABASE LINK orc1.world CONNECT TO proxy_refresher IDENTIFIED BY proxy_refresher; /************************************************************************* STEP 3: CREATE SNAPSHOT GROUP *************************************************************************/ --The following procedures must be executed by the snapshot administrator --at the remote snapshot site. CONNECT snapadmin/snapadmin@snap1.world --The master group that you specify in the GNAME parameter must match the --name of the master group that you are replicating at the target master site. BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPGROUP ( gname => 'SCOTT_MG', master => 'ORC1.WORLD', propagation_mode => 'ASYNCHRONOUS'); END; / /************************************************************************* STEP 4: CREATE REFRESH GROUP *************************************************************************/ --All snapshots that are added to a particular refresh group are --refreshed at the same time. This ensures transactional consistency --between the related snapshots in the refresh group. BEGIN DBMS_REFRESH.MAKE ( name => 'SNAPADMIN.SCOTT_RG', list => '', next_date => SYSDATE, interval => 'sysdate + 1/24', implicit_destroy => FALSE, rollback_seg => '', push_deferred_rpc => TRUE, refresh_after_errors => FALSE); END; / /************************************************************************* STEP 5: ADD OBJECTS TO SNAPSHOT GROUP *************************************************************************/ --Whenever you create a snapshot, always specify the schema name of the table --owner in the query for the snapshot. In the examples below, SCOTT is specified --as the owner of the table in each query. BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT ( gname => 'SCOTT_MG', sname => 'SCOTT', oname => 'BONUS', type => 'SNAPSHOT', ddl_text => 'create snapshot SCOTT.BONUS refresh fast with primary key for update as select * from SCOTT.BONUS@orc1.WORLD', min_communication => TRUE); END; / BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT ( gname => 'SCOTT_MG', sname => 'SCOTT', oname => 'DEPT', type => 'SNAPSHOT', ddl_text => 'create snapshot SCOTT.DEPT refresh fast with primary key for update as select * from SCOTT.DEPT@orc1.WORLD', min_communication => TRUE); END; / BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT ( gname => 'SCOTT_MG', sname => 'SCOTT', oname => 'EMP', type => 'SNAPSHOT', ddl_text => 'create snapshot SCOTT.EMP refresh fast with primary key for update as select * from SCOTT.EMP@orc1.WORLD', min_communication => TRUE); END; / BEGIN DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT ( gname => 'SCOTT_MG', sname => 'SCOTT', oname => 'SALGRADE', type => 'SNAPSHOT', ddl_text => 'create snapshot SCOTT.SALGRADE refresh fast with primary key for update as select * from SCOTT.SALGRADE@orc1.WORLD', min_communication => TRUE); END; / /************************************************************************* STEP 6: ADD OBJECTS TO REFRESH GROUP *************************************************************************/ --All of the snapshot group objects that you add to the refresh group --are refreshed at the same time to preserve referential integrity --between related snapshots. BEGIN DBMS_REFRESH.ADD ( name => 'SNAPADMIN.SCOTT_RG', list => 'SCOTT.BONUS', lax => TRUE); END; / BEGIN DBMS_REFRESH.ADD ( name => 'SNAPADMIN.SCOTT_RG', list => 'SCOTT.dept', lax => TRUE); END; / BEGIN DBMS_REFRESH.ADD ( name => 'SNAPADMIN.SCOTT_RG', list => 'SCOTT.emp', lax => TRUE); END; / BEGIN DBMS_REFRESH.ADD ( name => 'SNAPADMIN.SCOTT_RG', list => 'SCOTT.salgrade', lax => TRUE); END; /
|
![]() Copyright © 1999 Oracle Corporation. All Rights Reserved. |
|