create materialized view [ view_name ]
refresh [ fast|complete|force ]
[
on [commit|demand ] |
start with (start_time) next (next_time)
]
as
{创建物化视图用的查询语句}
具体实例如下:
CREATE MATERIALIZED VIEW an_user_base_file_no_charge
REFRESHCOMPLETE START WITH SYSDATE
NEXT TRUNC(SYSDATE+29)+5.5/24 --红色 部分表示从指定的时间开始,每隔一段时间(由next指定)就刷新一次
AS
select distinct user_no
from cw_arrearage t
where (t.mon = dbms_tianjin.getLastMonth or
t.mon = add_months(dbms_tianjin.getLastMonth, -1))
删除物化视图:
drop materialized view an_user_base_file_no_charge;