0

我有一个物化视图,我需要将特定功能添加到 MView 中包含的列之一。功能是如果 column 的值为 Y,则调用特定的包,否则就按原样。我知道我们不能使用 DECODE 进行快速刷新,所以我尝试使用 UNION ALL 并将其拆分为 2 个查询。

create materialized view test_mview 
(
col1,
col2,
..
)
build immediate
fast refresh 
with primary key as
select p_tes_pkg(ta.col1), ta.col2,.. 
from table_a ta, table_b tb, table_c tc 
where ta.id = tb.ta_id 
  and tb.code = tc.tb_code 
  and ta.col1 = 'Y' 
  and tb.type in ('ABC','DEF')
  and tb.type_id is not null
  and ta.code = tc.ta_code
  and regexp_like (ta.name, '^[[:digit:]]+$')
union all 
select ta_2.col1, ta_2.col2,.. 
from table_a ta_2, table_b tb_2, table_c tc_2 
where ta_2.id = tb_2.ta_id 
  and NVL(ta_2.col1,'N') = 'N'
  and tb_2.code = tc_2.tb_code
  and tb_2.type in ('ABC','DEF')
  and tb_2.type_id is not null
  and ta_2.code = tc.ta_code
  and regexp_like (ta_2.name, '^[[:digit:]]+$')
;

这仍然给出相同的错误。因此,我尝试使用选择查询创建一个视图并使用它来创建 MView。还是一样的错误。请提前帮助和感谢。

错误:

ORA-12015: cannot create a fast refresh materialized view from a complex query
12015. 00000 -  "cannot create a fast refresh materialized view from a complex query"
*Cause:    Neither ROWIDs and nor primary key constraints are supported for
           complex queries.
*Action:   Reissue the command with the REFRESH FORCE or REFRESH COMPLETE
           option or create a simple materialized view.
4

0 回答 0