create user mvadmin identified by
mvadmin;
begin
dbms_repcat_admin.
grant_admin_any_schema(username=> ’mvadmin’);
end;
/
grant comment any table to mvadmin;
grant lock any table to mvadmin;
grant select any dictionary to mvadmin;
2.注册传播方:
begin
dbms_defer_sys.register_propagator(
username => ’mvadmin’);
end;
/
3.公共数据库连接。需要每个复制需要创建三个数据库连接。公共数据库连接指定数据库的全局名称:
create public database link ORACLSH using ’Oracle.shanghai.
com’;
Using子句后跟的是全局数据库名或者是连接字符串。
create public database link ORACLSH using ’(description=
(address=(protocol=tcp)(host=127.0.0.1)(port=1521))
(connect_data=(service_name=oracl)))’
4.建立清除延迟事务队列调度作业:
disconnect;
connect mvadmin/mvadmin@BJ;
begin
dbms_defer_sys.schedule_purge(
next_date => sysdate,
interval => ’/*1:hr*/ sysdate + 1’,
delay_seconds => 0,
rollback_segment => ’’);
end;
5.建立复制管理员mvadmin的数据库连接:
create database link ORACLSH connect to proxy_bjOracle
identified by proxy_bjoralce
Connect to ... Identified by ...子句指明用什么用户连接远程数据库
6.建立复制调度数据库连接作业:
begin
dbms_defer_sys.schedule_push(
destination => ’ora92zjk’,interval => ’/*1:hr*/ sysdate + 1’,
next_date => sysdate,stop_on_error => false,
delay_seconds => 0,parallelism => 0);
end;
/
7.授予SHORACL用户(对应SHORACL方案)相应的权限建立实体化视图:
disconnect;
connect system/passwd@BJ;
grant alter session to crm;
grant create cluster to crm;
grant create database link to crm;
grant create sequence to crm;
grant create session to crm;
grant create synonym to crm;
grant create table to crm;
grant create view to crm;
grant create procedure to crm;
grant create trigger to crm;
grant unlimited tablespace to crm;
grant create type to crm;
grant create any snapshot to crm;
grant alter any snapshot to crm;
8.建立复制方案的数据库连接:
disconnect;
connect SHORACL/SHORACL@BJ;
create database link ORACLSH connect to ORACL identified
by ORACL;
复制方案的数据库连接和复制管理员的数据库连接要和system用户间里的对应公共数据库连接使用相同的名字,在调度连接时将使用公共数据库连接中指定的数据库全局名或者连接字符串。
9.建立实体化视图:
disconnect;
connect mvadmin/mvadmin@BJ;
create materialized view SHORACL.CREDIT_CARD refresh fast
wit h pr imar y key as sele ct * from ORA CL.
CREDIT_CARD@ORACLSH;
@后面是数据库连接名。如果该表没有主键则使用rowid来刷新。
create materialized view SHORACL. CREDIT_CARD refresh
fast with rowid as select * from ORACL. CREDIT_CARD@ORACLSH;
10.为多个视图建立刷新组:
begin
dbms_refresh.make (
name => ’mvadmin.sh_refresh’,list => ’’,
next_date => sysdate,interval => ’sysdate + 1’,
implicit_destroy => false,rollback_seg => ’’,
push_deferred_rpc => true,refresh_after_errors => false);
end;