ORACLE MVIEW
CREATE MATERIALIZED VIEW MV_EVT_LEDG
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
START WITH TO_DATE('16-02-2017 07:00:00', 'DD-MM-YYYY HH24:MI:SS') NEXT SYSDATE + 1
AS
SELECT BULD_NM,
a.ELEVATOR_NO,
ELVTR_ASIGN_NO,
ELVTR_STTS_CD,
C.COMPANY_NM,
C.sub_COMPANY_NM,
C.CONT_BEGIN_DATE,
C.CONT_END_DATE,
AREA_NO,
SIGUNGU_CD,
SEL_CHK_MM,
A.ELVTR_MGT_NO1, A.ELVTR_MGT_NO2, DECODE(A.ELVTR_STTS_CD,'01','정상','휴지') ELVTR_STTS_NM,B.BULD_MGT_NO1,B.BULD_MGT_NO2,B.ADDRESS1||B.ADDRESS2 as address from tn_elvtr_ledg a, tn_buld_ledg b, (SELECT ELEVATOR_NO, A.KEEP_MNT_CONT_NO,
CONT_BEGIN_DATE,
CONT_END_DATE,
B.ELEVATOR_NO_YN,
nvl(B.SEL_CHK_MM,1) SEL_CHK_MM,
A.COMPANY_CD,
SUB_COMPANY_CD,
BULD_MGT_NO1,
BULD_MGT_NO2,
ELVTR_MGT_NO1,
ELVTR_MGT_NO2,
A.CONT_DIV,
C.COMPANY_NM,
C.REPRSNT_CPNY_CD AS REPRSNT_CPNY_CD1,
D.COMPANY_NM SUB_COMPANY_NM,
D.REPRSNT_CPNY_CD AS REPRSNT_CPNY_CD2
FROM TB_KEEP_MNT_CONT A,
TB_KEEP_MNT_CONT_ELVTR B,
TN_CPNY_LEDG C,
TN_CPNY_LEDG D
WHERE A.KEEP_MNT_CONT_NO = B.KEEP_MNT_CONT_NO
AND A.COMPANY_CD = C.COMPANY_CD(+)
AND A.SUB_COMPANY_CD = D.COMPANY_CD(+)
AND A.IS_APPROVED = 'Y'
AND B.ELEVATOR_NO_YN = 'Y') c
WHERE a.buld_mgt_no1 = b.buld_mgt_no1
AND a.buld_mgt_no2 = b.buld_mgt_no2
AND a.ELVTR_MGT_NO1 = c.elvtr_mgt_no1(+)
AND a.ELVTR_MGT_NO2 = c.elvtr_mgt_no2(+)
AND A.ELVTR_UNIQUE_NO IS NOT NULL
AND a.ELVTR_STTS_CD IN ('01', '02')
mview job : select * from user_jobs;
mview log : select * from dba_mview_logs
refresh : execute dbms_refresh.refresh('AAA"."MV_EVT_LEDG"');
======
MVIEW 생성..
CREATE MATERIALIZED VIEW test_mv1
TABLESPACE TS_TOMS_01
REFRESH FAST ON COMMIT
--with rowid 0.
AS
SELECT * FROM test
--MVIEW 로그 생성
create materialized view log on test with rowid, primary key including new values
--MVIEW 로그 삭제
drop MATERIALIZED VIEW LOG on test
--MVIEW 생성 내역
select log_owner, master, log_table, rowids, primary_key
from dba_mview_logs
-- job 갱신
alter materialized view [view_name] refresh next sysdate + 1;