oracle中创建物化视图的步骤(MV)

1、在SOURCE DB 上建立日志
CREATE MATERIALIZED VIEW LOG ON MESPRD.LOT
TABLESPACE TS_IMESTRX_01
PCTUSED    0
PCTFREE    60
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          5M
            NEXT             5M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOCACHE
LOGGING
NOPARALLEL
WITH PRIMARY KEY
EXCLUDING NEW VALUES;

2、在目标DB上建立物化视图(基于PK)
 
CREATE MATERIALIZED VIEW  RPTPRD.FPALOT
TABLESPACE TS_DRPTTRX_01
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
USING INDEX
            TABLESPACE TS_IRPTMST_01
REFRESH FAST
START WITH SYSDATE
NEXT SYSDATE + 10/1440 
WITH PRIMARY KEY
AS 
SELECT * FROM 
WHERE lotstate = 'Released' ;
 
 
3、在目标DB上建立物化视图(基于普通索引)
 
CREATE MATERIALIZED VIEW AB01 
TABLESPACE BASE_DATA
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
REFRESH FORCE
START WITH SYSDATE
NEXT SYSDATE + 12/24  
WITH ROWID
AS 
SELECT * FROM ;
CREATE UNIQUE INDEX AB01_AAB001_IDX ON AB01
(AAB001)
LOGGING
TABLESPACE BASE_IDX
NOPARALLEL;


你可能感兴趣的:(oracle中创建物化视图的步骤(MV))