--給用戶授權 GRANT CREATE MATERIALIZED VIEW TO CDR; --創建物化視圖的表日志(具體到某個表,物化視圖中用到幾個表就需要建立幾個日志);當用FAST選項創建物化視圖,必須創建基於主表的視圖日志,如下: CREATE MATERIALIZED VIEW LOG ON a TABLESPACE CDR WITH ROWID; --查詢物化視圖日志 SELECT * FROM MLOG$_A --創建物化視圖 CREATE MATERIALIZED VIEW VIEW_A BUILD IMMEDIATE REFRESH FORCE--/FAST/COMPLETE ON DEMAND--/COMMIT WITH ROWID AS SELECT * FROM A; --查詢物化視圖 SELECT * FROM VIEW_A --刷新物化視圖,命令窗口執行 EXEC DBMS_MVIEW.REFRESH('VIEW_A','C');--完全刷新 EXEC DBMS_MVIEW.REFRESH('VIEW_A','F'); --快速刷新 --刪除物化視圖日志 DROP MATERIALIZED VIEW LOG ON A; --刪除物化視圖 DROP MATERIALIZED VIEW VIEW_A;
