Question

I created a fast refresh MV in a remote db by using a syntax like follows:

CREATE MATERIALIZED VIEW  MV_TAB1 
REFRESH FAST WITH PRIMARY KEY 
START WITH SYSDATE NEXT SYSDATE+(5/1440) /* 5 MINUTES */ 
FOR UPDATE AS 
SELECT * FROM TAB1@SOURCE_DB;

Now in the remote db where the MV_TAB1 was created, is it possible to update the MV_TAB1 and keep the update even after the refresh? My testing shows that after each refresh, my update on MV_TAB1 is gone. Is there any way to keep this local update? If yes,how?

Thanks, Amos

Was it helpful?

Solution

MV_TAB1 is an image of TAB1@SOURCE_DB, so you can't have it in the same time like TAB1 and different to TAB1.

If you update some rows on destination table and then update them in the source, the refresh will overwrite them. If you dont update them in the source they will remain updated ONLY if you use refresh fast. A refresh complete will delete/truncate the remote table and reinsert all rows.

UPDATE: If you want updates on remote table to have priority over the refresh, you can to some tricks:

1) keep the MV as it is and do updates(and inserts) on a sister table with the same DDL. The query, instead of MV, will use both tables, something like:

select nvl(a.key, b.key), decode(a.key, null, b.col, a.col)
from tab1_sister a 
full join mv_tab1 b on (a.key = b.key);

2) Add columns to the MV_TAB1(duplicate them, except the key) and do the updates on those columns (it is possible that MV must be with prebuilt table). If the additional columns are completed, use them, otherwise use the original columns updated by the refresh.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top