I wanted a Materialized View with fast refresh (update on the contained tables update). The materialized view query is something like:
SELECT T1.CODE, T2.NAME
FROM T1
UNION ALL
SELECT T2.CODE, T3.NAME
FROM T2, T3
WHERE T2.ID = T3.ID
It appears that in case of using UNION ALL
I should add ROWID
to achieve fast refresh.
Adding ROWID
is ok for the first part, but for the second part it can not be added as it has a join.
It seems there are 2 options to overcome this:
- Adding a redundant column for
NAME
onT2
and remove theT3
from query. Adding a virtual column containing a function that selects name from
T3
likeNAME NVARCHAR2(4000) GENERATED ALWAYS AS ("SCHEMA"."GET_NAME_FROM_OTHER_TABLE"("ID"))
According to this link: http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php it says:
Materialized views that access the virtual column must be fully refreshed.
and
If it refers to a deterministic user-defined function, it cannot be used as a partitioning key column.
Could I still have a Fast Refresh option on the materialized view using Solution 2?