ORACLE建立物化视图

时间:2023-03-09 17:32:07
ORACLE建立物化视图
--使用 on commit 的方式建立物化视图
create materialized view emp_dept refresh on commit
as
select t.*,d.dname from emp t , dept d
where t.deptno = d.deptno; --使用 on demand的方式建立物化视图
create materialized view mv_name refresh force on demand start with sysdate
next to_date( concat( to_char( sysdate+1,'dd-mm-yyyy'),' 22:00:00'),'dd-mm-yyyy hh24:mi:ss')
as
select t.*,d.dname from emp t
left join dept d
on t.deptno = d.deptno; --用left join 不能使用 on commit 的刷新方式,但是能使用 on demand的刷新方式
create materialized view emp_dept1 refresh force on commit
as
select t.*,d.dname from emp t
left join dept d
on t.deptno = d.deptno;