Fast Refresh Nested Materialized View problem in ORACLE 9i 9.2.0.7

Hello
My problem is in creating fast refresh nested materialized view in oracle 9i
In below is an example of my problem
( I need to say when I run this example in Oracle 11g all things is OK )
create table ali.alitest1(id number primary key,n1 number,n2 number);
create table ali.alitest2(id number primary key,n3 number);
CREATE MATERIALIZED VIEW LOG ON ali.alitest1 WITH ROWID,PRIMARY KEY ,SEQUENCE
(n1,n2)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON ali.alitest2 WITH ROWID,PRIMARY KEY ,SEQUENCE
(n3)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW ali.alitest1_mv
REFRESH WITH PRIMARY KEY FAST
AS
select id,n1 from ali.alitest1;
CREATE MATERIALIZED VIEW LOG ON ali.alitest1_mv WITH ROWID,PRIMARY KEY ,SEQUENCE
(n1)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW ali.alitest2_mv
REFRESH WITH PRIMARY KEY FAST
AS
select t1.id,t1.n1,t2.n3,t1.rowid "t1_rowid",t2.rowid "t2_rowid" from ali.alitest1_mv t1,ali.alitest2 t2 where t1.id=t2.id;
SQL Error: ORA-12053: this is not a valid nested materialized view
12053. 00000 - "this is not a valid nested materialized view"
*Cause:    The list of objects in the FROM clause of the definition of this
materialized view had some dependencies upon each other.
*Action:   Refer to the documentation to see which types of nesting are valid.
do you know what is problem ?
thanks

Take look for this link :
http://rwijk.blogspot.com/2009/08/fast-refreshable-materialized-view.html

Similar Messages

  • Problem in fast refreshing nested materialized views

    Hi all,
    While developing an ODS(Operational Data Store) system, i've created base materialized views from production database to ODS database which would use fast refresh. Now, i need to create nested Materialized views on these base MViews which contains joins and aggregations which should refresh on FAST mechanism.
    But while doing so, got several problems though Nested materialized views can be built using Complete Mechanism. The reporting queries is important and we want it should not hit the production database, rather it should hit the ODS db. But we are failing to build the Nested Materialized views which works on FAST.
    I tried google, oracle docs but all in vain. i tried to do a simple testing which also failed. I would be grateful if anyone can help in in this regard. I'm attaching the test case experimented,
    SCOTT >CREATE MATERIALIZED VIEW LOG ON EMP
    2 WITH ROWID, SEQUENCE(EMPNO, ENAME, JOB,
    3 MGR, HIREDATE, SAL,
    4 COMM, DEPTNO)
    5 INCLUDING NEW VALUES;
    Materialized view log created.
    Elapsed: 00:00:00.03
    SCOTT >
    SCOTT >CREATE MATERIALIZED VIEW LOG ON DEPT
    2 WITH ROWID, SEQUENCE(DEPTNO, DNAME, LOC)
    3 INCLUDING NEW VALUES;
    Materialized view log created.
    Elapsed: 00:00:00.06
    SCOTT >
    SCOTT >CREATE MATERIALIZED VIEW MV_EMP
    2 NOCACHE
    3 ENABLE ROW MOVEMENT
    4 NOLOGGING
    5 NOCOMPRESS
    6 PARALLEL(DEGREE DEFAULT INSTANCES DEFAULT)
    7 BUILD IMMEDIATE
    8 REFRESH FAST ON DEMAND
    9 WITH ROWID
    10 ENABLE QUERY REWRITE
    11 AS
    12 SELECT * FROM EMP;
    Materialized view created.
    Elapsed: 00:00:00.21
    SCOTT >
    SCOTT >CREATE MATERIALIZED VIEW MV_DEPT
    2 NOCACHE
    3 ENABLE ROW MOVEMENT
    4 NOLOGGING
    5 NOCOMPRESS
    6 PARALLEL(DEGREE DEFAULT INSTANCES DEFAULT)
    7 BUILD IMMEDIATE
    8 REFRESH FAST ON DEMAND
    9 WITH ROWID
    10 ENABLE QUERY REWRITE
    11 AS
    12 SELECT * FROM DEPT;
    Materialized view created.
    Elapsed: 00:00:00.14
    SCOTT >CREATE MATERIALIZED VIEW LOG ON MV_EMP
    2 WITH ROWID, SEQUENCE(EMPNO, ENAME, JOB,
    3 MGR, HIREDATE, SAL,
    4 COMM, DEPTNO)
    5 INCLUDING NEW VALUES;
    Materialized view log created.
    Elapsed: 00:00:00.04
    SCOTT >
    SCOTT >CREATE MATERIALIZED VIEW LOG ON MV_DEPT
    2 WITH ROWID, SEQUENCE(DEPTNO, DNAME, LOC)
    3 INCLUDING NEW VALUES;
    Materialized view log created.
    Elapsed: 00:00:00.03
    SCOTT >
    SCOTT >CREATE MATERIALIZED VIEW MV_EMP_DEPT
    2 NOCACHE
    3 ENABLE ROW MOVEMENT
    4 NOLOGGING
    5 NOCOMPRESS
    6 PARALLEL(DEGREE DEFAULT INSTANCES DEFAULT)
    7 BUILD IMMEDIATE
    8 REFRESH FAST ON DEMAND
    9 WITH ROWID
    10 ENABLE QUERY REWRITE
    11 AS
    12 SELECT D.ROWID DEPT_ROWID, E.ROWID EMP_ROWID, E.ENAME, D.DNAME, D.LOC, E.JOB, E.SAL
    13 FROM MV_EMP E,
    14 MV_DEPT D
    15 WHERE E.DEPTNO=D.DEPTNO;
    FROM MV_EMP E,
    ERROR at line 13:
    ORA-12053: this is not a valid nested materialized view
    Elapsed: 00:00:00.17
    SCOTT >
    SCOTT >CREATE MATERIALIZED VIEW MV_EMP_DEPT
    2 NOCACHE
    3 ENABLE ROW MOVEMENT
    4 NOLOGGING
    5 NOCOMPRESS
    6 PARALLEL(DEGREE DEFAULT INSTANCES DEFAULT)
    7 BUILD IMMEDIATE
    8 REFRESH FORCE ON DEMAND
    9 WITH ROWID
    10 ENABLE QUERY REWRITE
    11 AS
    12 SELECT D.ROWID DEPT_ROWID, E.ROWID EMP_ROWID, E.ENAME, D.DNAME, D.LOC, E.JOB, E.SAL
    13 FROM MV_EMP E,
    14 MV_DEPT D
    15 WHERE E.DEPTNO=D.DEPTNO;
    Materialized view created.
    Elapsed: 00:00:00.25
    SCOTT >
    SCOTT >EXECUTE DBMS_MVIEW.REFRESH('MV_EMP','F');
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.04
    SCOTT >EXECUTE DBMS_MVIEW.REFRESH('MV_DEPT','F');
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.04
    SCOTT >EXECUTE DBMS_MVIEW.REFRESH('MV_EMP_DEPT','F');
    BEGIN DBMS_MVIEW.REFRESH('MV_EMP_DEPT','F'); END;
    ERROR at line 1:
    ORA-12004: REFRESH FAST cannot be used for materialized view "SCOTT"."MV_EMP_DEPT"
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2254
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2460
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2429
    ORA-06512: at line 1
    Elapsed: 00:00:00.11
    SCOTT >EXECUTE DBMS_MVIEW.REFRESH('MV_EMP_DEPT','C');
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.35
    SCOTT >

    Sorry,
    By mistake this got posted in the CERTIFICATION forum,
    you can view the same question in the following link:
    Problem in fast refreshing nested materialized views

  • Fast refresh of materialized view

    Hi All,
    This is my first posting on this forum, so I hope I don't step on anyone's toes as I wade into a problem that I am experiencing.
    I have a number of either join-only or single table aggregate materialized views that I have experienced problems with. All the views are setup for FAST REFRESH ON DEMAND but I'm hitting an error if I execute a COMPLETE refresh of the view when I've done an ALTER SESSION ENABLE PARALLEL DML. The error I get is:
    ERROR at line 1:
    ORA-30439: refresh of 'DTKTGT.CTNS_PER_HR_VOL_AGG_MV' failed because of ORA-32320: REFRESH FAST of "DTKTGT"."CTNS_PER_HR_VOL_AGG_MV" unsupported after cointainer table PMOPs
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 814
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 872
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 852
    ORA-06512: at "DTKTGT.MV_REFRESH", line 21
    ORA-06512: at line 2
    Any help anyone could provide would be greatly appreciated as every now and then, a COMPLETE refresh is unavoidable and using the ENABLE PARALLEL DML makes the refresh run a lot faster than without the ALTER SESSION.
    Gary

    This forum only is for questions relating to the use of OLAP Option. I would post your question on the database forum.
    Keith Laker
    Oracle Data Warehouse Product Management
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • Erro perforing Fast Refresh of Materialized View.

    Hi Experts,
    We are facing serious problem while refreshing materialized views using fast refresh option in ORACLE..
    For the very first time we are performing Complete refresh of data from DB1 to DB2 for few tables.Ongoing we are performing Fast Refresh.
    Sometimes the fast refresh works fine without any error and sometimes it fails with the below error.
    ERROR at line 1:
    ORA-32320: REFRESH FAST of "CIR"."C_BO_COMM" unsupported after cointainer table
    PMOPs
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 803
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 860
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 841
    ORA-06512: at line 1we came to know the folowing.
    // *Cause:
      A Partition Maintenance Operation (PMOP) has been performed on the materialized view,
      and no materialized view supportsfast refersh after container table PMOPs.
    // *Action:
                   Use REFRESH COMPLETE.
         Note: 
                   you can determine why your materialized view does not support fast refresh after PMOPs using
                   the DBMS_MVIEW.EXPLAIN_MVIEW() API.Please let u know what action to be taken to avoid this.
    Please note that this error is not repeated always. Some times REFRESH FAST is happening and some times it is throwing error.
    Appreicate your earliest reply.
    Thank you.
    Edited by: User71408 on Sep 4, 2008 11:40 PM
    Edited by: User71408 on Sep 4, 2008 11:43 PM
    Edited by: User71408 on Sep 5, 2008 12:38 AM

    9i doesn't support fast refresh after truncate. Read the metalink note 275325.1
    You should be sure no truncate has been executed, or use complete refresh.
    Nicolas.

  • Fast Refresh in Materialized Views Partitioned

    Hi all.. I've a little problem... let's go into it:
    I have two tables:
    A dimension table , named D1
    A partitioned fact table, named F1
    I create two materialized views log in each of 2 tables.
    Ok.. Now, I created a Materialized View Partitioned, name MV_F1D1, with incremental refresh for it...
    I can create the Materialized View Partitioned with fast refresh, no problem here...
    First time Oracle make a Complete refresh, everything ok.. Then I make a
         BEGIN
              DBMS_SNAPSHOT.REFRESH('MV_F1D1','F');
         END;
    And everything goes well...
    But.. In my fact tables, I load the data with a temporary table, named F1_NP (Fact table no partitionated)
    with the data of the current month. Every week I do this:
    1) Load the data in F1_NP
    2) If the LAST_PARTITION_MM_YYYY not exists in F1, I add the partition to F1...
    3) ALTER TABLE F1 EXCHANGE PARTITION LAST_PARTITION_MM_YYYY WITH TABLE F1_NP
    And, this is the problem....
    After that process, the Log table of F1 is empty..
    When i'm trying to fast refresh the mv_F1D1, I got an error
         ORA-12097 changes in the master tables during refresh, try refresh:
    THis occurs when only I truncate a partition
    in the fact table too.
    Ok.. My only solution here is to make a complete refresh.. But I have only a new partition. I expected that with the PCT, Oracle let me
    do it a fast refresh.      
    I'm looking for a solution in the web, and I installed the utlxmnv.sql:
    1) Before add a partition in F1
    truncate table mv_capabilities_table;
    exec DBMS_MVIEW.EXPLAIN_MVIEW ( 'MV_F1D1' );
    select * from mv_capabilities_table;
    PCT Y
    REFRESH_COMPLETE Y
    REFRESH_FAST Y
    REWRITE Y
    PCT_TABLE Y F1
    PCT_TABLE N D1 2068 Relation is not partitioned.
    REFRESH_FAST_AFTER_INSERT Y
    REFRESH_FAST_AFTER_ONETAB_DML Y
    REFRESH_FAST_AFTER_ANY_DML Y
    REFRESH_FAST_PCT Y
    REWRITE_FULL_TEXT_MATCH Y
    REWRITE_PARTIAL_TEXT_MATCH Y
    REWRITE_GENERAL Y
    REWRITE_PCT Y
    PCT_TABLE_REWRITE Y F1
    PCT_TABLE_REWRITE N D1 2068 Relation is not partitioned.
    2) After truncate a partition in F1
    truncate table mv_capabilities_table;
    exec DBMS_MVIEW.EXPLAIN_MVIEW ( 'MV_F1D1');
    select * from mv_capabilities_table;
    PCT Y
    REFRESH_COMPLETE Y
    REFRESH_FAST Y
    REWRITE Y
    PCT_TABLE Y F1
    PCT_TABLE N D1 2068 Relation is not partitioned.
    REFRESH_FAST_AFTER_INSERT N F1 2077 Mv log is newer than last full refresh
    REFRESH_FAST_AFTER_INSERT N F1 2077 Mv log is newer than last full refresh
    REFRESH_FAST_AFTER_ONETAB_DML N 2146
    REFRESH_FAST_AFTER_ANY_DML N F1 2076
    REFRESH_FAST_AFTER_ANY_DML N 2161
    REFRESH_FAST_PCT Y
    REWRITE_FULL_TEXT_MATCH Y
    REWRITE_PARTIAL_TEXT_MATCH Y
    REWRITE_GENERAL Y
    REWRITE_PCT Y
    PCT_TABLE_REWRITE Y F1
    PCT_TABLE_REWRITE N D1 2068 Relation is not partitioned.
    BEGIN
              DBMS_SNAPSHOT.REFRESH('MV_F1D1','F');
    END;
    ORA-32313: REFRESH FAST of "MV_F1D1" unsupported after PMOPs
    any ideas? Can I fast refresh a MV partitioned (composed with a Table Dimension and Fact table)
    with PCT when I add data in the Dimension Table/add a partition in a Fact Table Partitioned?

    Look at ATOMIC_REFRESH option, if you set this to FALSE you may see performance gain as it'll use DIRECT PATH and TRUNCATE. Data will be unavailable while being refreshed though.
    Cheers
    Si

  • Fast refresh on MATERIALIZED VIEW

    Oracle 10 g R2 (10.2.0.5)
    CREATE MATERIALIZED VIEW scott.mv_test
    TABLESPACE users
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY
    AS
    Select ....
    I have this MV, when I do the FAST refersh as follows , I am getting error
    SQL> execute DBMS_MVIEW.REFRESH( 'MV_TEST','f');
    BEGIN DBMS_MVIEW.REFRESH( 'MV_TEST','f'); END;
    ERROR at line 1:
    ORA-12004: REFRESH FAST cannot be used for materialized view "SCOTT"."MV_TEST"
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2251
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2457
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2426
    ORA-06512: at line 1
    But it's working with Complete refresh.
    Is that expecte, any help would be appreciated.
    Thanks,

    ORA-12004: REFRESH FAST cannot be used for materialized view "string"."string"
    Cause:      The materialized view log does not exist or cannot be used. PCT refresh is also not enabled on the materialized view
    Action:      Use just REFRESH, which will reinstantiate the entire table. If a materialized view log exists and the form of the materialized view allows the use of a materialized view log or PCT refresh is possible after a given set of changes, REFRESH FAST will be available starting the next time the materialized view is refreshed.http://ora-12004.ora-code.com/

  • Fast Refresh on Materialized View With Join

    Hi All,
    i have created following Materialized View Logs and MV
    on EMP and DEPT
    CREATE MATERIALIZED VIEW LOG ON DEPT
    WITH PRIMARY KEY,SEQUENCE
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW LOG ON EMP
    WITH PRIMARY KEY,SEQUENCE
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW EMP_MVW
    TABLESPACE OSMIS_REPORT_DATA
    REFRESH FAST ON COMMIT
    AS
    SELECT A.EMPNO,A.ENAME,A.DEPTNO,A.JOB,A.MGR,A.HIREDATE,A.SAL,A.COMM,B.DNAME,B.LOC
    FROM EMP A,DEPT B
    WHERE A.DEPTNO=B.DEPTNO
    The Create MV Stmnt raised following error.
    ERROR at line 6:
    ORA-12052: cannot fast refresh materialized view SCOTT.EMP_MVW
    I have tried the same with ROWID also,but same error
    while creating MV.
    Pls anyone give idea to Fast Refersh on MV with Joins
    Thnks
    Raj.G.
    mail : [email protected]

    Actually you can get Oracle to tell you why the view does not have the capabilities you want using the DBMS_MVIEW package. For example you could have done something like this...
    Personal Oracle Database 10g Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> CREATE MATERIALIZED VIEW LOG ON dept
      2    WITH PRIMARY KEY, SEQUENCE
      3      INCLUDING NEW VALUES;
    Materialized view log created.
    SQL> CREATE MATERIALIZED VIEW LOG ON emp
      2    WITH PRIMARY KEY,SEQUENCE
      3      INCLUDING NEW VALUES;
    Materialized view log created.
    SQL> CREATE MATERIALIZED VIEW emp_mvw
      2    REFRESH FAST ON COMMIT
      3  AS
      4  SELECT a.empno, a.ename, a.deptno,
      5         a.job, a.mgr, a.hiredate,
      6         a.sal, a.comm, b.dname, b.loc
      7  FROM   emp a,dept b
      8  WHERE  a.deptno = b.deptno;
    FROM   emp a,dept b
    ERROR at line 7:
    ORA-12052: cannot fast refresh materialized view SCOTT.EMP_MVW
    SQL> CREATE MATERIALIZED VIEW emp_mvw
      2    REFRESH ON COMMIT -- remove the FAST to allow view to compile
      3  AS
      4  SELECT a.empno, a.ename, a.deptno,
      5         a.job, a.mgr, a.hiredate,
      6         a.sal, a.comm, b.dname, b.loc
      7  FROM   emp a,dept b
      8  WHERE  a.deptno = b.deptno;
    Materialized view created.
    SQL> @\oracle\product\10.1.0\Db_1\RDBMS\ADMIN\utlxmv.sql -- create mv_capabilities_table
    Table created.
    SQL> EXEC DBMS_MVIEW.EXPLAIN_MVIEW ('EMP_MVW');
    PL/SQL procedure successfully completed.
    SQL> SELECT capability_name, possible, msgtxt
      2  FROM   mv_capabilities_table
      3  WHERE  capability_name LIKE '%REFRESH_FAST_AFTER%';
    CAPABILITY_NAME                P MSGTXT
    REFRESH_FAST_AFTER_INSERT      N the SELECT list does not have the rowids of all the detail tables
    REFRESH_FAST_AFTER_INSERT      N mv log must have ROWID
    REFRESH_FAST_AFTER_INSERT      N mv log must have ROWID
    REFRESH_FAST_AFTER_ONETAB_DML  N see the reason why REFRESH_FAST_AFTER_INSERT is disabled
    REFRESH_FAST_AFTER_ANY_DML     N see the reason why REFRESH_FAST_AFTER_ONETAB_DML is disabled
    SQL> DROP MATERIALIZED VIEW LOG ON dept;
    Materialized view log dropped.
    SQL> DROP MATERIALIZED VIEW LOG ON emp;
    Materialized view log dropped.
    SQL> DROP MATERIALIZED VIEW emp_mvw;
    Materialized view dropped.
    SQL> CREATE MATERIALIZED VIEW LOG ON dept
      2    WITH ROWID, SEQUENCE
      3      INCLUDING NEW VALUES;
    Materialized view log created.
    SQL> CREATE MATERIALIZED VIEW LOG ON emp
      2    WITH ROWID,SEQUENCE
      3      INCLUDING NEW VALUES;
    Materialized view log created.
    SQL> CREATE MATERIALIZED VIEW emp_mvw
      2    REFRESH FAST ON COMMIT
      3  AS
      4  SELECT a.ROWID emp_rowid, b.ROWID dept_rowid,
      5         a.empno, a.ename, a.deptno,
      6         a.job, a.mgr, a.hiredate,
      7       a.sal, a.comm, b.dname, b.loc
      8  FROM   emp a,dept b
      9  WHERE  a.deptno = b.deptno;
    Materialized view created.
    SQL> DELETE mv_capabilities_table;
    18 rows deleted.
    SQL> EXEC DBMS_MVIEW.EXPLAIN_MVIEW ('EMP_MVW');
    PL/SQL procedure successfully completed.
    SQL> SELECT capability_name, possible, msgtxt
      2  FROM   mv_capabilities_table
      3  WHERE  capability_name LIKE '%REFRESH_FAST_AFTER%';
    CAPABILITY_NAME                P MSGTXT
    REFRESH_FAST_AFTER_INSERT      Y
    REFRESH_FAST_AFTER_ONETAB_DML  Y
    REFRESH_FAST_AFTER_ANY_DML     Y
    SQL>

  • Fast refresh of "materialized view with joins only"

    Hi,
    My Requirement:
    I need to create a materialized view joining two tables.
    Table1 -> Does not have primary key
    Table2 -> Has a primary key
    I need to refesh the mat view only when DML commands are done on Table1 alone.
    And it will be better if i have a Refresh on commit rather on demand.
    The following code is what i used and it dint work for me:
    CREATE MATERIALIZED VIEW LOG ON Table1 WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON Table2;
    CREATE MATERIALIZED VIEW AAYT_ETF
    REFRESH FORCE ON COMMIT
    ENABLE QUERY REWRITE
    AS
    SELECT A.rowid "table1_rowid", A.ACCTNUM, A.CORR_NUM, A.OFC_NUM, A.RR_NUM, A.BUY_SELL_CDE, A.ACT_AMT, A.CSP_SYM, A.SECR_DESC, A.ACT_QTY
    FROM Table1 A, Table2 G WHERE
    A.CSP_NUM = G.CSP_NUM AND
    G.ASST_SUB_STYP = 'ETF';
    Issue Faced: In this case the refresh happends even while i do DML on Table2.
    But i need the refresh only when i do DML on Table1. I also unable to create Refresh Fast Mat view.
    Can anyone please tell me how to create the Materialized view Log and the Materialized view. Thanks in advance.

    This forum only is for questions relating to the use of OLAP Option. I would post your question on the database forum.
    Keith Laker
    Oracle Data Warehouse Product Management
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • Materialized view (fast refresh mode) + Materialized view log on another DB

    Hi all,
    I created a materizalied view using this script :
    CREATE MATERIALIZED VIEW GIPS.DOSSIER_MEDICAL_MV2
    TABLESPACE GIPS_T
    NOCACHE
    NOLOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    USING INDEX
    TABLESPACE GIPS_I
    + REFRESH FAST ON DEMAND +
    START WITH TO_DATE('11-janv.-2011 16:00:00','dd-mon-yyyy hh24:mi:ss')
    NEXT sysdate (1/96)+
    AS
    SELECT N0_SEQ_BLOB_PDF,
    EXAM_ID,
    MPR,
    RSM,
    rub,
    date_deb,
    SPE,
    commentaire,
    SPR,
    MEP,
    MSJ,
    TTD,
    exam_type
    FROM DOSSIER_MEDICAL@dbdoc_lk
    WHERE DOSSIER_MEDICAL.EXAM_TYPE IN ('TELEM', 'SCANNER', 'EPPO_SECMED');
    So you can see I'm using a dblink in the select statement ( DBDOC_LK )
    On the DB referenced by this dblink, I created a materialized view log using this script :
    CREATE MATERIALIZED VIEW LOG ON "DOSMED"."DOSSIER_MEDICAL"
    TABLESPACE "DOC_T"
    WITH PRIMARY KEY
    INCLUDING NEW VALUES;
    The problem is that my materialized view has never refreshed since its creation ! and I don't understand why ?
    Can someone help me ?
    Thank you.

    The REFRESH schedule causes a job to be created for the execution of the Refresh. You should see this job in DBA_JOBS / USER_JOBS.
    The job would run only if the instance parameter JOB_QUEUE_PROCESSES is set to 1 or higher (the default is 0). This parameter can be modified dynamically with an ALTER SYSTEM command.
    Hemant K Chitale
    http://hemantoracledba.blogspot.com

  • How can I fast refresh the  materialized view !!

    I created a MV base on some tables in order to improve the querey speed.
    but the mv I have created falied to refresh fast.
    because there are two same table in the from clause:
    jcdm jc1,jcdm jc2
    create materialized view temp_mv
    nologging
    pctfree 0
    storage (initial 2048k next 2048k pctincrease 0)
    parallel
    build immediate
    refresh force
    on demand
    as
    select
    TAB_GSHX.rowid hx_rid,
    TAB_GSHD.rowid hd_rid ,
    JC1.rowid jc1_rid ,
    JC2.rowid jc2_rid ,
    YSHD_ID     HXID,          
    JC1.JCDM     QFD,     
    JC2.JCDM     JLD     
    FROM
    TAB_GSHX,
    TAB_GSHD,
    jCDM JC1,
    JCDM JC2
    WHERE
    YSHD_ID=YSHX_ID
    AND YSHD_QFD=JC1.JBJC_ID
    AND YSHD_JLD=JC2.JBJC_ID
    AND TO_CHAR(YSHX_time,'YYYYMMDD')='20030101'
    the column msgtxt of the table MV_CAPABILITIES_TABLE is :
    "the multiple instances of the same table or view" and " one or more joins present in mv".
    How can I succeed in fast refresh the above temp_mv!!!
    thanks.

    lianjun,
    When you are using Oracle9i there is a procedure which can help you setup the materialized view. If some option isn't working it gives you hint why it doesn't work.
    The procedure is dbms_mview.explain_mview.
    Take a look at the documentation how to use it. (In the Oracle9i DWH guide the package is explained.)
    Hope this helps
    With kind regards,
    Bas Roelands

  • Fast refresh of materialized view on remote database

    Hi All,
    I have the following scenario, two databases called ORCL_1 and ORCL_2
    ORCL_1 (11.1.0.7) ORCL_2 (10.2.0.1)
    EMPLOYEE (Master table)
    DEPARTMENT (Master table)
    I have created materialied view logs on both the master tables as follows...
    create materialized view log on department
    with rowid, sequence(department_id, department_name)
    including new values
    create materialized view log on employee
    with rowid, sequence (employee_no, surname, firstname, title, department_id, dob, dependants)
    including new values
    On ORCL_1 i have created a materialized view as follows...
    create materialized view employee_mview
    build immediate
    refresh on demand with rowid
    as select e.employee_no, e.title, e.firstname, e.surname, d.department_name, d.department_id, e.dob, e.dependants, e.rowid emp_rowid, d.rowid dept_rowid
    from employee@ORCL_2 e,
    department@ORCL_2 d
    where e.department_id = d.department_id
    then i have a scheduled task, on ORCL_1, that execute "...dbms_mview.refresh ('mac_dba.employee_mview','?');...." every minute
    this works fine, except for the fact that all the records are deleted from the materialized view and then all the records are re-inserted.
    How can i get it so that only the records that have been added or amended, as per the materialized view logs, are refreshed to the materialized view.
    thanks
    Mel

    Hi Harry,
    Have tried creating materialized view as follows...
    create materialized view mac_dba.employee_mview
    build immediate
    refresh fast on demand with rowid
    as select e.employee_no, e.title, e.firstname, e.surname, d.department_name, d.department_id, e.dob, e.dependants, e.rowid emp_rowid, d.rowid dept_rowid
    from mac_dba.employee@ORCL_2 e,
    mac_dba.department@ORCL_2 d
    where e.department_id = d.department_id
    I get the following error message
    ORA-12028: materialized view type is not supported by master site
    thanks
    Mel

  • How to speed up fast refresh of materialized view without primary key

    Thought I'd share this info, as I couldn't find anything on here to help me diagnose the issue:
    I had a materialized view that was taking longer to perform a fast refresh than it took to perform a complete refresh. My mview had no primary key, as the base table had no primary key.
    I created a trace file for the session and saw references to a column M_ROW$$ in my mview. Nowhere in the data dictionary could I find a reference to the m_row$$ column in my mview, but apparently it exists and is created automatically. After creating the index below, the fast refresh took 6 minutes to add 500k rows to the materialized view. (versus 4+ hours without the index) When I looked in the trace file, I noticed that for each row in the mview log, it first tries to update the mview with an UPDATE statement, then it performs an insert of the new data. Seems like it should be able to determine whether to perform an update or insert based on the DMLTYPE$$ column of the mview log. What was killing my performance was the UPDATE phase. Since I had no primary key on the mview, and no index on the m_row$$ column, the UPDATE phase was performing a full table scan of my mview for every row in the mview log. I was expecting it to be smart enough to only perform inserts, as the only transactions against the base table were inserts.
    In summary: If you have a materialized view without a primary key, create an index on the m_row$$ column of the mview, even though no such column displays in the data dictionary.
    ex:
    CREATE MATERIALIZED VIEW mv_minidrr ...
    CREATE INDEX pk_mv_minidrr ON mv_minidrr(m_row$$) ...

    Well, there indeed is a column called M_ROW$$
    Your MLOG$_EMP is nothing but the materialized view log on the base table.
    SQL> create  materialized view log on emp with rowid ;
    Materialized view log created.
    SQL> create materialized view emp_mview refresh fast on demand with rowid as select * from emp ;
    Materialized view created.
    SQL> desc mlog$_emp
    Name                                                  Null?    Type
    M_ROW$$                                                        VARCHAR2(255)
    SNAPTIME$$                                                     DATE
    DMLTYPE$$                                                      VARCHAR2(1)
    OLD_NEW$$                                                      VARCHAR2(1)
    CHANGE_VECTOR$$                                                RAW(255)
    SQL> select table_name, column_name from user_tab_columns where column_name = 'M_ROW$$' ;
    TABLE_NAME                     COLUMN_NAME
    MLOG$_EMP                      M_ROW$$
    1 row selected.
    SQL>

  • Query rewrites with Nested materialized views with different aggregations

    Platform used : Oracle 11g.
    Here is a simple fact table (with measures m1,m2) and dimensions (a) Location (b) Calendar and (c) Product. The business problem is that aggregation operator for measure m1,m2 are different along location dimension and Calendar dimension. The intention is to preaggregate the measures for a product along the calendar dimension and Location dimension and store it as materialized views.
    The direct option is to define a materialized view with Inline queries (Because of the different aggrergation operator, it is not possible to write a query without Inline query). http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28313/qradv.htm#BABEAJBF documents the limitations that it works only for 'Text match' and 'Equivalent queries' and that is too limiting.
    So decided to have nested materialized view, with first view having just joins(my_dim_mvw_joins), the second view having aggregations along Calendar dimension (my_dim_mvw_calendar) and third view having aggregations along the Location dimension(my_dim_mvw_location). Obviously I do not want the query I fire to know about materialized views and I fire it against the fact table. I see that for the fired query (Which needs aggregations along both Calendar and Location), is rewritten with just second materialized view but not the third. (Had set QUERY_REWRITE_INTEGRITY as TRUSTED) .
    Wanted to know whether there are limitations on Query Writes with nested materialized views? Thanks
    (Have given a simple testable example below. Pls ignore the values given in 'CALENDAR_IDs', 'PRODUCT_IDs' etc as they are the same for all the queries)
    -- Calendar hierarchy table
    CREATE TABLE CALENDAR_HIERARCHY_TREE
    (     "CALENDAR_ID" NUMBER(5,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(5,0),
    "HIERARCHY2_ID" NUMBER(5,0),
    "HIERARCHY3_ID" NUMBER(5,0),
    "HIERARCHY4_ID" NUMBER(5,0),
    CONSTRAINT "CALENDAR_HIERARCHY_TREE_PK" PRIMARY KEY ("CALENDAR_ID")
    -- Location hierarchy table
    CREATE TABLE LOCATION_HIERARCHY_TREE
    (     "LOCATION_ID" NUMBER(3,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(3,0),
    "HIERARCHY2_ID" NUMBER(3,0),
    "HIERARCHY3_ID" NUMBER(3,0),
    "HIERARCHY4_ID" NUMBER(3,0),
    CONSTRAINT "LOCATION_HIERARCHY_TREE_PK" PRIMARY KEY ("LOCATION_ID")
    -- Product hierarchy table
    CREATE TABLE PRODUCT_HIERARCHY_TREE
    (     "PRODUCT_ID" NUMBER(3,0) NOT NULL ENABLE,
         "HIERARCHY1_ID" NUMBER(3,0),
         "HIERARCHY2_ID" NUMBER(3,0),
         "HIERARCHY3_ID" NUMBER(3,0),
         "HIERARCHY4_ID" NUMBER(3,0),
         "HIERARCHY5_ID" NUMBER(3,0),
         "HIERARCHY6_ID" NUMBER(3,0),
         CONSTRAINT "PRODUCT_HIERARCHY_TREE_PK" PRIMARY KEY ("PRODUCT_ID")
    -- Fact table
    CREATE TABLE RETAILER_SALES_TBL
    (     "PRODUCT_ID" NUMBER,
    "PRODUCT_KEY" VARCHAR2(50 BYTE),
    "PLAN_ID" NUMBER,
    "PLAN_PERIOD_ID" NUMBER,
    "PERIOD_ID" NUMBER(5,0),
    "M1" NUMBER,
    "M2" NUMBER,
    "M3" NUMBER,
    "M4" NUMBER,
    "M5" NUMBER,
    "M6" NUMBER,
    "M7" NUMBER,
    "M8" NUMBER,
    "LOCATION_ID" NUMBER(3,0),
    "M9" NUMBER,
    CONSTRAINT "RETAILER_SALES_TBL_LOCATI_FK1" FOREIGN KEY ("LOCATION_ID")
    REFERENCES LOCATION_HIERARCHY_TREE ("LOCATION_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_PRODUC_FK1" FOREIGN KEY ("PRODUCT_ID")
    REFERENCES PRODUCT_HIERARCHY_TREE ("PRODUCT_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_CALEND_FK1" FOREIGN KEY ("PERIOD_ID")
    REFERENCES CALENDAR_HIERARCHY_TREE ("CALENDAR_ID") ENABLE
    -- Location dimension definition to promote query rewrite
    create DIMENSION LOCATION_DIM
    LEVEL CHAIN IS LOCATION_HIERARCHY_TREE.HIERARCHY1_ID
    LEVEL CONSUMER_SEGMENT IS LOCATION_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL STORE IS LOCATION_HIERARCHY_TREE.LOCATION_ID
    LEVEL TRADING_AREA IS LOCATION_HIERARCHY_TREE.HIERARCHY2_ID
    HIERARCHY PROD_ROLLUP (
    STORE CHILD OF
    CONSUMER_SEGMENT CHILD OF
    TRADING_AREA CHILD OF
    CHAIN
    -- Calendar dimension definition
    create DIMENSION CALENDAR_DIM
    LEVEL MONTH IS CALENDAR_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL QUARTER IS CALENDAR_HIERARCHY_TREE.HIERARCHY2_ID
    LEVEL WEEK IS CALENDAR_HIERARCHY_TREE.CALENDAR_ID
    LEVEL YEAR IS CALENDAR_HIERARCHY_TREE.HIERARCHY1_ID
    HIERARCHY CALENDAR_ROLLUP (
    WEEK CHILD OF
    MONTH CHILD OF
    QUARTER CHILD OF
    YEAR
    -- Materialized view with just joins needed for other views
    CREATE MATERIALIZED VIEW my_dim_mvw_joins build immediate refresh complete enable query rewrite as
    select product_id, lht.HIERARCHY1_ID, lht.HIERARCHY2_ID, lht.HIERARCHY3_ID, lht.location_id, cht.HIERARCHY1_ID year,
    cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week, m1, m3, m7, m9
    from retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    -- Materialized view which aggregate along calendar dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_calendar build immediate refresh complete enable query rewrite as
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID ,location_id, year, quarter, month, week,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total,
    GROUPING_ID(product_id, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_joins
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id,
    rollup (year, quarter, month, week);
    -- Materialized view which aggregate along Location dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_location build immediate refresh complete enable query rewrite as
    select product_id, year, quarter, month, week, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1,
    GROUPING_ID(product_id, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_calendar
    GROUP BY product_id, year, quarter, month, week,
    rollup (HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id)
    -- SQL Query Fired (for simplicity have used SUM as aggregation operator for both, but they will be different)
    select product_id, year, HIERARCHY1_ID, HIERARCHY2_ID,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1
    from
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , year,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total
    from
    select product_id, lht.HIERARCHY1_ID , lht.HIERARCHY2_ID , lht.HIERARCHY3_ID ,lht.location_id, cht.HIERARCHY1_ID year, cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week,m1,m3,m7,m9
    from
    retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id, year
    ) sales_time
    GROUP BY product_id, year,HIERARCHY1_ID, HIERARCHY2_ID
    This Query rewrites only with my_dim_mvw_calendar. (as saw in Query Plan and EXPLAIN_MVIEW). But we would like it to use my_dim_mvw_location as that has aggregations for both dimensions.

    blackhole001 wrote:
    Hi all,
    I'm trying to make my programmer's life easier by creating a database view for them to query the data, so they don't have to worry about joining tables. This sounds like a pretty horrible idea. I say this because you will eventually end up with programmers that know nothing about your data model and how to properly interact with it.
    Additionally, what you will get is a developer that takes one of your views and see's that of the 20 columns in it, it has 4 that he needs. If all those 4 columns comes from a simple 2 table join, but the view has 8 tables, you're wasting a tonne of resources by using the view (and heaven forbid they have to join that view to another view to get 4 of the 20 columns from that other view as well).
    Ideally you'd write stored routines that satisfy exactly what is required (if you are the database resource and these other programmers are java, .net, etc... based) and the front end developers would call those routines customized for an exact purpose.
    Creating views is not bad, but it's by no means a proper solution to having developers not learn or understand SQL and/or the data model.

  • Replication of database views/materialized views from big oracle to mobile client

    Hi all,
    Has anyone done a replication of a view or a materialized view
    from big oracle to oracle lite? I can get replication of a
    database table happening(although I cant seem to find the table
    when I log into the odb using msql) but it just doesn't seem to
    work with views(hence the path I have taken which is to use
    materialized views). Anyone? Cheers

    Hello,
    Yesterday I met the same problem and very sad about this, however, my story is much more complicated (I think so).
    I have 6 databases:
    2 - 11g
    2 - 10g
    2 - 9i
    Every database of each release has different characterset(UTF8 and AL16UTF16).
    I am trying to create Materialized view with FAST REFRESH on Oracle 11g, when master tables are located on 10g database and 9i database.
    Materialized view, which points to 9i database, was successfully created.
    Materialized view, which points to 10g database, gets ORA-12028
    Like you, I tried many notes from METALINK and thought at the begining that the problem is my characterset. But, when the materialized views were successfully built on Oracle 9i database, I understood that the problem is something else.
    Did you find the actual reason why this issue does not work??
    Thanks,
    Alex

  • How can I manually refresh a Materialized View

    Hi,
    There's a materialized view created in 2006 as under:
    CREATE MATERIALIZED VIEW "schema"."mv_name"
    USING INDEX
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE AS SELECT * FROM "table_name@dblink;
    The problem is that the last refresh was done in Aug. I want to manually refresh this materialized view right now as there is a procedure based on this MV and its not showing the right data as the above materialized view has not been refreshed, so the data for this month is not showing.
    Please let me know how I can refresh that MV right now.
    Also do I need to change the refresh option. How can I change it so that the MV refreshes itself every second.
    Thanks

    Also do I need to change the refresh option. How can
    I change it so that the MV refreshes itself every
    second. Every second? Why do you want to do that?? Perhaps waht you really want is refresh the MV on commit.

Maybe you are looking for

  • The home button on my iPod Touch 4G is barely working!

    I have to press my home button and my sleep button about 10 times to get it to respond, does anyone have any idea why both buttons would act up? My ipod is nearly full, as in MBs away from it, would that have anything to do with the slow movement??

  • Exporting as PDF from Keynote type problem

    Hi, I'm trying to export a Keynote presentation as a PDF for a client leave-behind, and the PDF is not showing all fonts correctly. Some slides have simple text boxes that Adobe Reader and Acrobat render as complete gibberish. Other screens have Numb

  • Drag and drop to grid AS2

    i want to create a grid where i can drag and drop items to it n save them, should i draw the grid myself and make a bunch of holders (as if i were making an inventory?) or is there a code i can use. i am pretty good with as2 but i never took the time

  • Transfer pictures from google+ to aperture

    Is it possible to add google+ under "share"? What is the best way to import pictures from google + to aperture?

  • Problem when transporting datasource

    Hi! I want to transport datasource 8ZC_PRCUSTM and 8ZC_PRCUSTT and but i have a return code 8 with these messages: <i>Extract structure /BIC/CE8ZC_PRCUSTM is not active The extract structure /BIC/CE8ZC_PRCUSTM of the DataSource 8ZC_PRCUSTM is invalid