首页 > 数据库 > Oracle > 物化视图刷新方式说明
1 建立一个可以成功快速刷新的例子,这个物化视图只包含连接: SQL> create materialized view log on dim_a with rowid; SQL> create materialized view log on dim_b with rowid; SQL> create materialized view log on fact with rowid; SQL> create materialized view mv_fact refresh fast on commit as 2 select f.rowid f_rowid, a.rowid a_rowid, b.rowid b_rowid, f.id, 3 a.name a_name, b.name b_name, num 4 from fact f, dim_a a, dim_b b 5 where f.aid = a.id 6 and f.bid = b.id;
1. 建立可以成功快速刷新的例子,这个物化视图只包含聚集: SQL> create materialized view log on fact with rowid, sequence (aid, num) 2 including new values; SQL> create materialized view mv_fact refresh fast on commit as 2 select aid, count(*) count, count(num) count_num, sum(num) sum_num 3 from fact group by aid; 2. 建立快速刷新的例子,物化视图包含聚集和连接: SQL> create materialized view log on fact with rowid, sequence (aid, num) 2 including new values; SQL> create materialized view log on dim_a with rowid, sequence (id, name) 2 including new values; SQL> create materialized view mv_fact refresh fast on commit as 2 select name, count(*) count, count(num) count_num, sum(num) sum_num 3 from fact, dim_a where aid = dim_a.id group by name;
1.建立一个符合快速刷新条件的UNION ALL物化视图 SQL> create materialized view log on dim_a with rowid; SQL> create materialized view log on dim_b with rowid; SQL> create materialized view log on fact with rowid; SQL> create materialized view mv_fact refresh fast on commit as 2 select f.rowid f_rowid, a.rowid row_id, a.name name, num, 'a' marker 3 from fact f, dim_a a 4 where f.aid = a.id 5 union all 6 select f.rowid f_rowid, b.rowid row_id, b.name name, num, 'b' marker 7 from fact f, dim_b b 8 where f.bid = b.id;
SQL> create materialized view log on dim_a with rowid; SQL> create materialized view log on dim_b with rowid; SQL> create materialized view log on fact with rowid; SQL> create materialized view mv_fact refresh fast on commit as 2 select f.rowid f_rowid, a.rowid a_rowid, b.rowid b_rowid, f.id, 3 a.name a_name, b.name b_name, num 4 from fact f, dim_a a, dim_b b 5 where f.aid = a.id 6 and f.bid = b.id; SQL> create materialized view log on mv_fact with rowid, sequence (a_name, num) 2 including new values; SQL> create materialized view mv_mv_fact refresh fast on commit as 2 select a_name, count(*) count, count(num) count_num, sum(num) sum_num 3 from mv_fact 4 group by a_name;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29424472/viewspace-1191201/ ,如需转载,请注明出处,否则将追究法律责任。