Oracle Material View
1. Oracle Material View syntax is as below
create materialized view [view_name]
refresh [fast|complete|force]
[ on [commit|demand]
|
start with (start_time) next (next_time) ]
as
{创建物化视图用的查询语句
1. Refresh Method
complete: 全部刷新。相当于重新执行一次创建视图的查询语句。
fast : 增量刷新.假设前一次刷新的时间为t1,那么使用fast模式刷新物化视图时,只向视图中添加t1到当前时间段内,主表变化过的数据.为了记录这种变化,建立增量刷新物化视图还需要一个物化视图日志表。create materialized view log on (主表名)。
force: 这是默认的数据刷新方式。当可以使用fast模式时,数据刷新将采用fast方式;否则使用complete方式。
2. Refresh Type
On demand: 在用户需要时,由用户刷新
On commit: 当主表中有数据提交的时候,立即刷新MV中的数据;
When we need to add schedule, we need to use start with and next
start ……:从指定的时间开始,每隔一段时间(由next指定)就刷新一次;
start with to_date('03-02-2012 14:50:59', 'dd-mm-yyyy hh24:mi:ss')
next to_date(concat(to_char(sysdate + 1, 'yyyy-MM-dd'), ' 22:00:00'), 'yyyy-MM-dd hh24:mi:ss')