Updatable materialized views
NunoJan 25 2013 — edited Jan 28 2013Environment: DB is Oracle 11g
I wanted to replicate part of my database in a offline laptop, using Materialized views (and refreshing them when the laptop would be online with the master DB).
So far, so good.
Step 2 was to allow some of those views to be changeable. So, I decided to use updatable MVs.
Question1: to create an updatable view, the master table must have a primary key?
Question2: the updatable command overrides the fast refresh, or they can (should) be used together?
I created the MV Log in the master
then the refresh group in remote
BEGIN
DBMS_REFRESH.MAKE ( name => 'my_group',
list => '',
next_date => '' , interval => '',
implicit_destroy => FALSE, rollback_seg => '',
push_deferred_rpc => TRUE, refresh_after_errors => FALSE);
END;
CREATE MATERIALIZED VIEW "TARGET_ACTIVITY" ("ID", "FAO_CODE", "NAME", "PARENT_ID") BUILD IMMEDIATE
REFRESH FORCE ON DEMAND NEXT NULL
USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS FOR UPDATE DISABLE QUERY REWRITE AS
SELECT "TARGET_ACTIVITY"."ID" "ID",
"TARGET_ACTIVITY"."FAO_CODE" "FAO_CODE",
"TARGET_ACTIVITY"."NAME" "NAME",
"TARGET_ACTIVITY"."PARENT_ID" "PARENT_ID"
FROM "TARGET_ACTIVITY"@"SERVIDOR" "TARGET_ACTIVITY";
Added view to refresh group
BEGIN
DBMS_REFRESH.add( name => 'my_group', list => 'TARGET_ACTIVITY', lax => TRUE);
END;
But whenever I refresh the group, the updates in the remote table are deleted and they do not update the master... shouldn't they pass to the master table AND stay in the remote table? Or did I get this updatable thing all wrong?
Thanks for any help