connect system/passwd@SH create user repadmin identified by repadmin; begin dbms_repcat_admin.grant_admin_any_schema( username=>’repadmin’); end; /grant comment any table to REPADMIN; grant lock any table to REPADMIN;
begin dbms_repcat.generate_replication_support( sname=>’SHORACL’, oname=>’ CREDIT_CARD’, type=>’TABLE’, min_communication=>TRUE); end; /
9. 为快速刷新创建实体化视图日志:
create materialized view log on SHORACL. CREDIT_CARD;
假如是没有主键的表示用一下语句:
create materialized view log on SHORACL. CREDIT_CARD with rowid excluding new values;
10.启动复制:
begin dbms_repcat.resume_master_activity( name=>’sh_rep’); end; /
二.设置实体化视图站点。 1.创建复制治理员并授予相应的权限:
disconnect; connect system/passwd@BJ; 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)))’
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;
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;