沧海一粟
自我介绍
切换风格
订阅我的Blog
博客日历
文章归档...
最新发表...
博客统计...
网站链接...
资源
===========================================================
mv for update 之三
===========================================================

增加一个表的过程

orc1:

create tab;

create mv log;

create_master_repobject

generate_replication_support

-----------------------------------

mv1:

create mv;

create_mview_repobject;

dbms_refresh.add;

详细过程如下:


增加一个表的过程
conn ww/ww@orc1
create table emp2 as select * from emp;
alter table emp2 add primary key (employee_id);
create materialized view log on emp2;

BEGIN
DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
gname => 'ww_repg',
type => 'TABLE',
oname => 'emp2',
sname => 'ww',
use_existing_object => TRUE,
copy_rows => FALSE);
END;
/

BEGIN
DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
sname => 'ww',
oname => 'emp2',
type => 'TABLE',
min_communication => TRUE);
END;
/

conn ww/ww@mv1
create materialized view emp2_mv1
REFRESH FAST WITH PRIMARY KEY FOR UPDATE
AS SELECT * FROM ww.emp2@orc1;

BEGIN
DBMS_REPCAT.CREATE_MVIEW_REPOBJECT (
gname => 'ww_repg',
sname => 'ww',
oname => 'emp2_mv1',
type => 'SNAPSHOT',
min_communication => TRUE);
END;
/

-- Step 6 Add objects to the refresh group.
BEGIN
DBMS_REFRESH.ADD (
name => 'ww.ww_repg',
list => 'ww.emp2_mv1',
lax => TRUE);
END;
/

SQL> select count(1) from emp2_mv1;

COUNT(1)
----------
108

SQL>
SQL> delete from emp2_mv1 where employee_id<100;

0 rows deleted.

SQL> c/100/200
1* delete from emp2_mv1 where employee_id<200
SQL> /

100 rows deleted.

SQL> select count(1) from emp2_mv1;

COUNT(1)
----------
8

SQL> commit;

Commit complete.
SQL> exec dbms_refresh.refresh('ww_repg');

PL/SQL procedure successfully completed.

SQL> select count(1) from ww.emp2@orcl;
select count(1) from ww.emp2@orcl
*
ERROR at line 1:
ORA-02019: connection description for remote database not found


SQL> select count(1) from ww.emp2@orc1;

COUNT(1)
----------
8

SQL>

wmlm 发表于:2012.02.09 12:06 ::分类: ( oracle ) ::阅读:(102次) :: 评论 (0) :: 引用 (0)

发表评论
标题

在此添加评论

称呼

邮箱地址(可选)

个人主页(可选)

authimage