zoukankan      html  css  js  c++  java
  • 物化视图,自己研究下吧

    DROP MATERIALIZED VIEW EDB.PRODUCTION_MATERIALIZED_VIEW;
    CREATE MATERIALIZED VIEW EDB.PRODUCTION_MATERIALIZED_VIEW
    (PANELID,TIMEKEY,EVENTTIME,FGCODE,OLDLINE,
    OLDPROCESSOPERATIONNAME,PROCESSOPERATIONNAME,REWORKSTARTSTEP,REASONCODE,GRADE,
    REVISIONCODE)
    TABLESPACE MES_BASIC_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    NEXT 1M
    MAXSIZE UNLIMITED
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    )
    NOCACHE
    LOGGING
    NOCOMPRESS
    BUILD IMMEDIATE
    REFRESH FORCE
    START WITH TO_DATE('13-01-2021 14:41:20','dd-mm-yyyy hh24:mi:ss')
    NEXT SYSDATE+15/24/60
    WITH PRIMARY KEY
    AS
    /* 格式化对象 2021/1/13 14:36:56 (QP5 v5.287) */
    SELECT /*+INDEX(P0 UN_PH_TIMEKEY_0)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY0@MESDB_LINK P0
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P1 UN_PH_TIMEKEY_1)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY1@MESDB_LINK P1
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P2 UN_PH_TIMEKEY_2)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY2@MESDB_LINK P2
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P3 UN_PH_TIMEKEY_3)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY3@MESDB_LINK P3
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P4 UN_PH_TIMEKEY_4)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY4@MESDB_LINK P4
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P5 UN_PH_TIMEKEY_5)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY5@MESDB_LINK P5
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P6 UN_PH_TIMEKEY_6)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY6@MESDB_LINK P6
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P7 UN_PH_TIMEKEY_7)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY7@MESDB_LINK P7
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P8 UN_PH_TIMEKEY_8)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY8@MESDB_LINK P8
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END
    UNION ALL
    SELECT /*+INDEX(P9 UN_PH_TIMEKEY_9)*/
    PANELID,
    TIMEKEY,
    EVENTTIME,
    FGCODE,
    OLDLINE,
    OLDPROCESSOPERATIONNAME,
    PROCESSOPERATIONNAME,
    REWORKSTARTSTEP,
    REASONCODE,
    GRADE,
    REVISIONCODE
    FROM PANELHISTORY9@MESDB_LINK P9
    WHERE TIMEKEY BETWEEN CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE - 1, 'YYYYMMDD') || '073000000'
    END
    AND CASE
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) > 730
    THEN
    TO_CHAR (SYSDATE + 1, 'YYYYMMDD') || '073000000'
    WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'HH24MI')) < 730
    THEN
    TO_CHAR (SYSDATE, 'YYYY/MM/DD') || '073000000'
    END;


    COMMENT ON MATERIALIZED VIEW EDB.PRODUCTION_MATERIALIZED_VIEW IS 'snapshot table for snapshot EDB.PRODUCTION_MATERIALIZED_VIEW';

  • 相关阅读:
    js篇之对象数据属性与存取器属性
    使用ts-loader与webpack编译typescripts出现Module build failed: TypeError: Cannot read property 'afterCompile' of undefined
    js对象深拷贝
    前端工程化之webpack中配置babel-loader(四)
    前端工程化-webpack篇之babel-polyfill与babel-runtime(三)
    process.cwd()与__dirname的区别
    jade(pug)学习和使用
    [bzoj4033][HAOI2015]树上染色_树形dp
    [bzoj2657][Zjoi2012]旅游 journey_ 对偶图_树形dp
    [bzoj2097][Usaco2010 Dec]Exercise 奶牛健美操_贪心_树形dp_二分
  • 原文地址:https://www.cnblogs.com/zhouchen0408/p/14271898.html
Copyright © 2011-2022 走看看