在物化视图上测试快速刷新

时间:2020-01-29 21:56:43

标签: oracle oracle12c

我想基于一个查询来创建一个具有每日快速刷新的实时实例化视图,该查询从3个表(PS_JOB,PS_DEPT_TBL,PSOPRDEFN)和1个视图(PS_NPS_LICCERT_VW)中获取字段。查询/过程看起来像这样。

CREATE MATERIALIZED VIEW LOG ON PS_JOB;

CREATE MATERIALIZED VIEW LOG ON PS_NPS_LICCERT_VW

CREATE MATERIALIZED VIEW LOG ON PSOPRDEFN

CREATE MATERIALIZED VIEW LOG ON PS_DEPT_TBL


CREATE MATERIALIZED VIEW ALL_EMP_CERTS
BUILD IMMEDIATE
REFRESH FAST
START WITH to_date   ('28-JAN-20','DD-MON-RR') --start on this date
NEXT sysdate +1               --next refresh every 1 days 
 AS 
 SELECT DISTINCT(A.EMPLID),E.OPRID,E.OPRDEFNDESC,B.JPM_DESCR90,B.JPM_DATE_3,B.JPM_DATE_6,H.DESCR,H.LOCATION FROM PS_JOB@PEOPLESOFT A
LEFT OUTER JOIN PS_NPS_LICCERT_VW@PEOPLESOFT B ON A.EMPLID=B.EMPLID 
LEFT OUTER JOIN PSOPRDEFN@PEOPLESOFT E ON A.EMPLID=E.EMPLID
LEFT OUTER JOIN PS_DEPT_TBL@PEOPLESOFT H ON A.DEPTID=H.DEPTID
  WHERE  a.EFFDT = (SELECT MAX(e.EFFDT) FROM PS_JOB@PEOPLESOFT e
        WHERE E.EFFDT <= sysdate
        and e.emplid = a.emplid
        and e.empl_rcd = A.EMPL_RCD)
        AND a.EFFseq = (SELECT MAX(f.EFFseq) FROM PS_JOB@PEOPLESOFT f
        WHERE f.EFFDT = a.effdt
        and f.emplid = a.emplid
        and f.empl_rcd = A.EMPL_RCD)
        AND A.PER_ORG = 'EMP'
        AND a.paygroup not in ('SUM','CWR')
        AND A.EMPL_STATUS in ('A', 'L', 'P', 'S');

但是,由于其视图,我无法在PS_NPS_LICCERT_VW上创建物化日志,并且在尝试时出现以下错误

CREATE MATERIALIZED VIEW LOG ON PS_NPS_LICCERT_VW
Error report -
ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"
*Cause:    
*Action

因此,我又在基表上创建了日志,这些日志通知了视图PS_NPS_LICCERT_VW

CREATE MATERIALIZED VIEW LOG ON PS_JPM_PROFILE@PEOPLESOFT WITH ROWID;
CREATE MATERIALIZED VIEW LOG ON PS_JPM_JP_ITEMS@PEOPLESOFT WITH ROWID;
CREATE MATERIALIZED VIEW LOG ON PS_JPM_CAT_TYPES@PEOPLESOFT WITH ROWID;
CREATE MATERIALIZED VIEW LOG ON PS_JPM_CAT_ITEMS@PEOPLESOFT WITH ROWID;

然后我放下了物化视图并再次创建它。

CREATE MATERIALIZED VIEW  ALL_EMP_CERTS_TEST
BUILD IMMEDIATE 
REFRESH FAST START WITH (SYSDATE) NEXT  (TRUNC(SYSDATE) + 1) + 4 / 24 WITH ROWID
DISABLE QUERY REWRITE
AS SELECT DISTINCT(A.EMPLID),E.OPRID,E.OPRDEFNDESC,B.JPM_DESCR90,B.JPM_DATE_3,B.JPM_DATE_6,H.DESCR,H.LOCATION FROM PS_JOB A
LEFT OUTER JOIN PS_NPS_LICCERT_VW@PEOPLESOFT B ON A.EMPLID=B.EMPLID 
LEFT OUTER JOIN PSOPRDEFN@PEOPLESOFT E ON A.EMPLID=E.EMPLID
LEFT OUTER JOIN PS_DEPT_TBL@PEOPLESOFT H ON A.DEPTID=H.DEPTID
  WHERE  a.EFFDT = (SELECT MAX(e.EFFDT) FROM PS_JOB e
        WHERE E.EFFDT <= sysdate
        and e.emplid = a.emplid
        and e.empl_rcd = A.EMPL_RCD)
        AND a.EFFseq = (SELECT MAX(f.EFFseq) FROM PS_JOB@PEOPLESOFT f
        WHERE f.EFFDT = a.effdt
        and f.emplid = a.emplid
        and f.empl_rcd = A.EMPL_RCD)
        AND A.PER_ORG = 'EMP'
        AND a.paygroup not in ('SUM','CWR')
        AND A.EMPL_STATUS in ('A', 'L', 'P', 'S');

我收到以下错误:


Error report -
ORA-12015: cannot create a fast refresh materialized view from a complex query
12015. 00000 -  "cannot create a fast refresh materialized view from a complex query"
*Cause:    Neither ROWIDs and nor primary key constraints are supported for
           complex queries.
*Action:   Reissue the command with the REFRESH FORCE or REFRESH COMPLETE
           option or create a simple materialized view.

关于如何解决此问题的任何建议。

0 个答案:

没有答案