为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。 【DM版本】:7 【操作系统】:麒麟 【CPU】:x86_64 【问题描述】*: 单纯的两个表 union ALL实现物化视图,但是fast更新提示如下图,请问如何配置?
带UNION ALL的快速刷新物化视图前提条件比较严格 1.UNION ALL必须在顶层; 2.每个分支查询必须符合快速刷新条件; 3.必须包含标识列,即报错提示的内容; 4.不允许外连接、源端表等 如果只是2个表单纯union all,查询频率不高的情况下,建议建普通视图即可; 如果确实需要快速刷新的物化视图,参考我这个例子:
create table t071901 (c1 int primary key, c2 varchar(10)); create table t071902 (c1 int primary key, c2 varchar(10)); create materialized view log on t071901 with primary key; create materialized view log on t071902 with primary key; create materialized view mtv_0719 REFRESH FAST WITH primary key on commit as select c1, c2, 1 marker from t071901 union all select c1, c2, 2 marker from t071902 ;
带UNION ALL的快速刷新物化视图前提条件比较严格
1.UNION ALL必须在顶层;
2.每个分支查询必须符合快速刷新条件;
3.必须包含标识列,即报错提示的内容;
4.不允许外连接、源端表等
如果只是2个表单纯union all,查询频率不高的情况下,建议建普通视图即可;
如果确实需要快速刷新的物化视图,参考我这个例子:
create table t071901 (c1 int primary key, c2 varchar(10)); create table t071902 (c1 int primary key, c2 varchar(10)); create materialized view log on t071901 with primary key; create materialized view log on t071902 with primary key; create materialized view mtv_0719 REFRESH FAST WITH primary key on commit as select c1, c2, 1 marker from t071901 union all select c1, c2, 2 marker from t071902 ;