Materialize view

HP_UX Oracle 10gR2
I am trying to create a materialized view with the following query
SQL> create materialized view log on sales with rowid,sequence(cust_id,prod_id,amount_sold,channel_id) including new values;
CREATE MATERIALIZED VIEW MV_SALES2
NOPARALLEL
BUILD IMMEDIATE
REFRESH Fast ON commit
AS
/* Formatted on 2010/11/29 06:03 (Formatter Plus v4.8.8) */
SELECT COUNT (*), prod_id, cust_id, MAX (promo_id), AVG (promo_id),
SUM (amount_sold), AVG (amount_sold),SUM (channel_id), MIN (channel_id),
MAX (channel_id)
FROM sales
GROUP BY prod_id, cust_id
I always get error
ERROR at line 10:
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
Can anybody explain me how can I resolve this problem?
Thanks in advance

I think the problem is that you didn't include PROMO_ID into the MV log, but use it in MV. Fast refresh is not possible in this case because the MV log does not contain all necessary data for this, and Oracle won't let you set ON COMMIT for a MV that's not fast-refreshable. The easiest way to verify if your MV is going to be fast-refreshable is to use DBMS_MVIEW.EXPLAIN_MVIEW procedure and check reported MV capabilities along with explanations why particular capability is not available.
@varun4dba: the note you referenced is not relevant to this case as it describes the behavior of MVs when a join is involved and one or more of the joined tables are IOT. No join in OP's case.

Similar Messages

  • Refresh Fast option in Materialize view

    Dear All,
    We have oracle 10g On windows.
    We have database A having SCOTT schema and tables Emp and Dept.
    I have another database B having TEST schema and this schema does not have any objects (Moto is to create mview on this database).
    We have created DB LINK between TEST schema to SCOTT schema and planning to create materialize view in TEST schema.
    Now I am confuse....
    1) I am creating mview in TEST schema and i want to refresh mview increamentally. I search on internet and found only if you want to use FAST REFRESH then you must have to create log table for the base table.
    --Query is
    1)  I am creating mview in TEST schema and my base tables are in SCOTT schema on different database. Where should i create log table(on SCOTT SCHEMA or TEST schema).
    2) Does this log tables will occupy more space or log table will truncate after refresh of mview.
    3) For using incremental refresh i need to use +REFRESH FORCE+ option or anything else.
    4) If log table will not truncate then it will occupy more space so is there anything that we can come up out of this situation.Thanks..

    1) You should create log in Scott Schema
    2)
    Managing Materialized View Log Space
    Oracle automatically tracks which rows in a materialized view log have been used during the refreshes of materialized views, and purges these rows from the log so that the log does not grow endlessly. Because multiple simple materialized views can use the same materialized view log, rows already used to refresh one materialized view might still be needed to refresh another materialized view. Oracle does not delete rows from the log until all materialized views have used them.
    For example, suppose two materialized views were created against the customers table in a master site. Oracle refreshes the customers materialized view at the spdb1 database. However, the server that manages the master table and associated materialized view log does not purge the materialized view log rows used during the refresh of this materialized view until the customers materialized view at the spdb2 database also refreshes using these rows.
    Because Oracle must wait for all dependent materialized views to refresh before purging rows from a materialized view log, unwanted situations can occur that cause a materialized view log to grow indefinitely when multiple materialized views are based on the same master table or master materialized view.
    For example, such situations can occur when more than one materialized view is based on a master table or master materialized view and one of the following conditions is true:
    One materialized view is not configured for automatic refreshes and has not been manually refreshed for a long time.
    One materialized view has an infrequent refresh interval, such as every year (365 days).
    A network failure has prevented an automatic refresh of one or more of the materialized views based on the master table or master materialized view.
    A network or site failure has prevented a master table or master materialized view from becoming aware that a materialized view has been dropped.
    Note:
    If you purge or TRUNCATE a materialized view log before a materialized view has refreshed the changes that were deleted, then the materialized view must perform a complete refresh.
    Purging Rows from a Materialized View Log
    Always try to keep a materialized view log as small as possible to minimize the database space that it uses. To remove rows from a materialized view log and make space for newer log records, you can perform one of the following actions:
    Refresh the materialized views associated with the log so that Oracle can purge rows from the materialized view log.
    Manually purge records in the log by deleting rows required only by the nth least recently refreshed materialized views.
    To manually purge rows from a materialized view log, execute the PURGE_LOG procedure of the DBMS_MVIEW package at the database that contains the log. For example, to purge entries from the materialized view log of the customers table that are necessary only for the least recently refreshed materialized view, execute the following procedure:
    3) REFRESH FAST
    4) See step 2

  • Can we do Dml statements on materialize views

    I want to know can we do Dml statements on materialize views .If yes, how

    Can you? Maybe. Depends on how you created the materialized view. Should you? Maybe. Are you running a multi-master environment? Or are you using materialized views for one-way replication? If you are doing one-way replication, do you want your DML changes to be retained beyond the next refresh of the materialized view?
    Justin

  • How to create Materialize view using Sysdate

    I need to create a materialize view having SYSDATE in its WHERE clause. Can i any let me know how can i do it. I know there is some documentation on that in ORACLE but i could not find it .
    Thanks

    What's the problem? This works on 8.1.7 (see below).
    Vibes, APC
    SQL> create snapshot s$test
      2  as select * from <my_table>
      3* where START_DATE = SYSDATE
    Materialized view created.
    SQL> select count(*) from s$test
      2  /
      COUNT(*)
             0
    SQL>

  • Materialize views logs

    hey gurus
    in my database we have some materialize views . and some of them are using clouse REFRESH COMPLETE and some are USING REFRESH FAST.my point of concern is " for a fast refresh we have to create mat. view logs".how can i check what are log exist for my database because i checked in all_object i havn't find any object with type = log . is it really a object else what it do when we run a DDL
    " create materialise view log on tablename ....."
    thanks in advance

    Seems to be working for me, but I don't have a machine that would even run 8.1.7 to test with. I have no experience with the old Server Manager tool, you might try using SQL*Plus instead.
    Describing a materialized view log, though, isn't particularly interesting. I created one on the EMP table
    SCOTT @ jcave102 Local> select * from dba_mview_logs;
    LOG_OWNER                      MASTER                         LOG_TABLE
    LOG_TRIGGER                    ROW PRI OBJ FIL SEQ INC
    SCOTT                          EMP                            MLOG$_EMP
                                   NO  YES NO  NO  NO  NO
    Elapsed: 00:00:00.01
    SCOTT @ jcave102 Local> desc mlog$_emp
    Name                                                  Null?    Type
    EMPNO                                                          NUMBER(4)
    SNAPTIME$$                                                     DATE
    DMLTYPE$$                                                      VARCHAR2(1)
    OLD_NEW$$                                                      VARCHAR2(1)
    CHANGE_VECTOR$$                                                RAW(255)and you'll see that most of the interesting bits are in the RAW(255) CHANGE_VECTOR$$ column.
    Justin

  • Disconnected when creating a materialize view

    when i try to create a materialize view from a "big" select (a select from several other selects), it doesn't create the view and i get disconnected from the database.

    Hi,
    Please make sure you are editing in Advanced Mode, then click the part of <WebPartPages:XsltListViewWebPart ...>
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Does Materialize Views comes with Standard One?

    Hi
    Does Materialize Views comes with Oracle 10g Standard One?
    Regards,
    Néstor Boscán

    Read this discussion: https://discussions.apple.com/message/16215112#16215112

  • How to find total refresh time of Materialize view?

    Hello All,
    I want to know the total refresh time of Materialize view. i m refreshing MV by below statement
    i hv not logging the start and end time of this in process.
    exec dbms_mview.refresh('EMP_MV','C','',FALSE,FALSE,0,0,0,TRUE);
    So, anybody can you please know the using which database table it cab be possible?
    Thanks in advance

    The only way you can log the refresh time for each execution is to wrap the call inside a procedure that also logs the start and end times to a logging table.
    (if you manually run the exec dbms_mview.refresh from an SQLPlus command line, you could also SET TIMING ON in SQLPlus)
    Hemant K Chitale

  • What is the main difference between view and materialize view and advantage of Mview   ??

    What is the main difference between view and materialize view and advantage of Mview   ??

    1.A view uses a query to pull data from its associated tables.
    2.Views do not have data's physically stored in the Database.
    3.Views Get the Data from 2 or more tables and displays as a single block.
    4.But a materialized view is a table on disk is a result set of a query done.
    5.A Materialized view can have data's in the database.
    6.Materialized view are used for Boosting the Performance.
    7.And the important one is Materialized views are updated based on the parameters defined when they are created.
    8.By using triggers we can update the data in a materialized view.
    9.When you call a materialized view it will show the data when it was last updated.
    Hope it helps.

  • ORA-02243:invalid ALTER INDEX or ALTER MATERIALIZES VIEW option

    Hi, Friend,
    I am changing all the index to another tablespace of one of my schema.When I run the DDL script,got the error:
    ORA-02243:invalid ALTER INDEX or ALTER MATERIALIZES VIEW option
    I checked the metalink, got nothing.Anyone can help? Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I also googled some info,like:
    Oracle Error :: ORA-02243
    invalid ALTER INDEX or ALTER MATERIALIZED VIEW option
    Cause
    An option other than INITRANS, MAXTRANS,or STORAGE is specified in an ALTER INDEX statement or in the USING INDEX clause of an ALTER MATERIALIZED VIEW statement.
    Action
    Specify only legal options.
    But I still can't find the clue.

  • Materialize view on oracle 9i and oracle 10g

    Hi,
    My sql query using Materialized view in from cluase.
    its execution time on oralce 9i 9.0.2 is only 0.25 sec but on oracle 10g it takes 4 minutes.
    Explain plan in oracle 9i it consider MV as table but in Oracle 10g it consider it as MV.
    i m analyze all the table before executing the query although it takes time to execute it
    Please can anyone hv the idea how to decrease the execution time.
    Thanks in advance.

    This is my QUERY
    SELECT pp.hhc_code hhc_code, descp.item_id lucode, pp.ctry_code country_code,
    pp.co_code company_code, descp.hq_descp_txt description
    FROM prod_descp_en descp,
    (SELECT DISTINCT ctry_code, co_code, item_id, hhc_code
    FROM prod_perf_xref
    WHERE procs_revis_nbr <= 1493) pp
    WHERE descp.ctry_code = pp.ctry_code
    AND descp.co_code = pp.co_code
    AND descp.item_id = pp.item_id
    AND EXISTS (
    SELECT 'X'
    FROM (SELECT prod_nbr, case_seq_nbr, prod_ctry_code, prod_co_code
    FROM ord_ship_ln
    WHERE (ord_ctry_code,
    ord_co_code,
    ord_doc_nbr,
    ord_sys_srce
    ) IN (
    SELECT ord_ctry_code, ord_co_code, ord_doc_nbr,
    ord_sys_srce
    FROM oms.ord_ship_hdr hr1
    WHERE ( ( hr1.acctg_dest_ctry = '119'
    AND hr1.acctg_dest_co = '003'
    AND hr1.acctg_dest_nbr = 131
    AND hr1.acctg_dest_type = '02'
    OR ( hr1.srce_ctry_code = '119'
    AND hr1.srce_co_code = '003'
    AND hr1.srce_loc_nbr = 131
    AND hr1.srce_loc_type_code = '02'
    ))) ln1
    WHERE descp.product_nbr = ln1.prod_nbr
    AND descp.case_nbr = ln1.case_seq_nbr
    AND descp.ctry_code = ln1.prod_ctry_code
    AND descp.co_code = ln1.prod_co_code)
    ORACLE -9i
    Plan
    SELECT STATEMENT CHOOSECost: 1,528 Bytes: 138 Cardinality: 1                                              
         16 HASH JOIN Cost: 1,528 Bytes: 138 Cardinality: 1                                         
              12 HASH JOIN SEMI Cost: 1,316 Bytes: 93 Cardinality: 1                                    
                   1 TABLE ACCESS FULL OMS.PROD_DESCP_EN Cost: 10 Bytes: 1,160,406 Cardinality: 20,358                               
                   11 VIEW SYS.VW_SQ_1 Cost: 1,290 Bytes: 515,484 Cardinality: 14,319                               
                        10 NESTED LOOPS Cost: 1,290 Bytes: 1,317,348 Cardinality: 14,319                          
                             8 TABLE ACCESS BY INDEX ROWID OMS.ORD_SHIP_HDR Cost: 138 Bytes: 31,104 Cardinality: 576                     
                                  7 BITMAP CONVERSION TO ROWIDS                
                                       6 BITMAP OR           
                                            3 BITMAP CONVERSION FROM ROWIDS      
                                                 2 INDEX RANGE SCAN NON-UNIQUE OMS.ORD_SHIP_HDR_DEST_IDX1 Cost: 1
                                            5 BITMAP CONVERSION FROM ROWIDS      
                                                 4 INDEX RANGE SCAN NON-UNIQUE OMS.ORD_SHIP_HDR_SRCE_INDX Cost: 1
                             9 INDEX RANGE SCAN UNIQUE OMS.PKORD_SHIPLN1 Cost: 2 Bytes: 950 Cardinality: 25                     
              15 VIEW OMS. Cost: 211 Bytes: 598,860 Cardinality: 13,308                                    
                   14 SORT UNIQUE Cost: 211 Bytes: 532,320 Cardinality: 13,308                               
                        13 TABLE ACCESS FULL MFIDATA.PROD_PERF_XREF_T Cost: 164 Bytes: 532,320 Cardinality: 13,308                          
    ORACLE -10g
    Plan
    SELECT STATEMENT CHOOSECost: 7,538 Bytes: 138 Cardinality: 1                                              
         19 HASH JOIN Cost: 7,538 Bytes: 138 Cardinality: 1                                         
              12 HASH JOIN SEMI Cost: 6,851 Bytes: 93 Cardinality: 1                                    
                   1 MAT_VIEW ACCESS FULL MAT_VIEW OMS.PROD_DESCP_EN Cost: 32 Bytes: 1,132,305 Cardinality: 19,865                               
                   11 VIEW VIEW SYS.VW_SQ_1 Cost: 6,612 Bytes: 2,585,376 Cardinality: 71,816                               
                        10 NESTED LOOPS Cost: 6,612 Bytes: 6,607,072 Cardinality: 71,816                          
                             8 TABLE ACCESS BY INDEX ROWID TABLE OMS.ORD_SHIP_HDR Cost: 805 Bytes: 156,114 Cardinality: 2,891                     
                                  7 BITMAP CONVERSION TO ROWIDS                
                                       6 BITMAP OR           
                                            3 BITMAP CONVERSION FROM ROWIDS      
                                                 2 INDEX RANGE SCAN INDEX OMS.ORD_SHIP_HDR_SRCE_INDX Cost: 6
                                            5 BITMAP CONVERSION FROM ROWIDS      
                                                 4 INDEX RANGE SCAN INDEX OMS.ORD_SHIP_HDR_DEST_IDX1 Cost: 1
                             9 INDEX RANGE SCAN INDEX (UNIQUE) OMS.PKORD_SHIPLN1 Cost: 2 Bytes: 950 Cardinality: 25                     
              18 VIEW OMS. Cost: 685 Bytes: 1,154,925 Cardinality: 25,665                                    
                   17 HASH UNIQUE Cost: 685 Bytes: 1,026,600 Cardinality: 25,665                               
                        16 VIEW VIEW MFIDATA.index$_join$_007 Cost: 511 Bytes: 1,026,600 Cardinality: 25,665                          
                             15 HASH JOIN                     
                                  13 INDEX RANGE SCAN INDEX MFIDATA.IDX_PROD_PERF_XREF_ROW_DELT Cost: 419 Bytes: 1,026,600 Cardinality: 25,665                
                                  14 INDEX FAST FULL SCAN INDEX (UNIQUE) MFIDATA.IND_PROD_PERF_XREF_INDEX1 Cost: 309 Bytes: 1,026,600 Cardinality: 25,665

  • Using Materialize View in a query

    Hi,
    Oracle Version 10g
    I have created 1 MV as per the below script from taking a data from diffrent schema.
    CREATE MATERIALIZED VIEW ERM_EMPLOYEE_MASTER_SYN
    REFRESH COMPLETE ON DEMAND
    START WITH TO_DATE('05-03-0012', 'DD-MM-YYYY') NEXT SYSDATE + 120/(24*60)
    AS
    SELECT "EMP_STAFFID","EMP_FIRSTNAME","EMP_LASTNAME","EMP_MIDDLENAME","EMP_LEGALNAME","EMP_COMPANYNAME","EMP_NICKNAME","EMP_SALUTATION","EMP_SUFFIX","EMP_SHIFTCODE","EMP_CALENDARCODE","EMP_MAILID","OU_ID","EMP_REPORTINGTO","EMP_FUNCTIONALREPORTINGTO","EMP_OFFICIATEID","EMP_SECRETARY" FROM HRMSADMIN.ERM_EMPLOYEE_MASTER WHERE EMP_ISACTIVE = '1' AND EMP_STAFFID NOT IN (SELECT EMP_STAFFID FROM HRMSADMIN.ERM_EMPLOYEE_MASTER WHERE TEMP_EMP_STAFFID ='TEMP')
    UNION
    SELECT "EMP_STAFFID","EMP_FIRSTNAME","EMP_LASTNAME","EMP_MIDDLENAME","EMP_LEGALNAME","EMP_COMPANYNAME","EMP_NICKNAME","EMP_SALUTATION","EMP_SUFFIX","EMP_SHIFTCODE","EMP_CALENDARCODE","EMP_MAILID","OU_ID","EMP_REPORTINGTO","EMP_FUNCTIONALREPORTINGTO","EMP_OFFICIATEID","EMP_SECRETARY
    FROM HRMSADMIN.ERM_CONTRACT_EMPLOYEES WHERE EMP_ISACTIVE = '1'
    Now when I am using the MV in a select sub query, query is taking time if I am using MV in a select statement
    like
    (SELECT (EMP_FIRSTNAME || ' ' || EMP_MIDDLENAME || ' ' ||
    EMP_LASTNAME) AS EMP_COMPANYNAME
    FROM *ERM_EMPLOYEE_MASTER_SYN* A, ASSIGNMENT_TEAMALLOCATION B
    WHERE A.EMP_STAFFID = B.TEAMMEMBER_ID
    AND B.TEAMTYPE_ID = 1
    AND B.ASSIGNMENT_ID = ASSMT.ASSIGNMENT_ID) TEAM_LEAD,
    Can you please suggest some solution how can I reduce the extraction time.
    I have tried to create a MV with Primary key but still same result
    MV has only 4000 records.
    Thanks
    Regards
    Anant

    Hello
    You need to provide more information. Have a look at the FAQ - specifically how to post a tuning request...
    SQL and PL/SQL FAQ
    David

  • Oracle doc inconsistent on materialize view with union all and self joins

    First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
    I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
    First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
    Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
    BUT
    In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
    You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
    Whenever I try to create the mview I get the following error. (
    In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.

    First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
    I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
    First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
    Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
    BUT
    In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
    You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
    Whenever I try to create the mview I get the following error. (
    In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.

  • Refreh of a materialized view!

    Dear All,
    My Oracle Database is 11gR1 and Linux is the OS.
    What I am trying to achieve by creating materialized view logs and materialize views is, that as soon as there is a change in materialize view log (master table) on remote site, the materialize view on another local server is also updated. Both system are on the same network.
    I mean this will be then very near to real time replication. If i specify a time limit then even if there is no change in master table, snapshot will be updated and it will depend on the data size how much time snapshot takes to update.
    So that's y i need to perform a snapshot update as soon as there is any change in materialize view log.
    What clause i need to specify while creating such a materialize view?
    REFRESH <FAST | FORCE> ON <COMMIT | DEMAND> is the clause i need to understand from you guys, what suits the best in my situation.
    Also please if there is another way to achieve this task using materialize view kindly do let me know. Maybe there is some other type of materialized view doing this. All my materialized views are based on single master table.
    Thanks a lot.
    Regards, Imran

    a. remote means a db_link, even if the db_link is a loop back (in the same database):
    e.g.
    SQL> create table mv_test(pk number primary key);
    Table created.
    SQL> create materialized view log on mv_test;
    Materialized view log created.
    SQL> create database link loop_back connect to ami identified by ami
      2  using 'ocm12';
    SQL> select * from dual@loop_back;
    D
    X
    SQL> create materialized view mv_test_check
      2  refresh on commit
      3  as select * from mv_test@loop_back;
    create materialized view mv_tet_check
    ERROR at line 1:
    ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    SQL> create materialized view mv_test_check
      2  refresh on commit
      3  as select * from mv_test;
    Materialized view created.b. no, you need to create a job that will call dbms_mview.refresh
    Amiel Davis

  • How to view the physical size of objects

    Hi
    Please advise how to view the physical size of objects like tables, indexes, materialize views etc.
    Wishes
    Jawad

    To see the physical size of objects like tables, indexes, use
    USER_SEGMENTS where SEGMENT_TYPE=table/index/partition etc.
    But for views/packages/java/trigger, you can only see rough estimate in USER_OBJECT_SIZE

Maybe you are looking for

  • No goods receipt possible for purchase order 'PO#" "Lineitem"

    Hi gurus, Please help on below error. While doing return to vendor transaction using BAPI 'BAPI_GOODSMVT_CREATE' error 'No goods receipt possible for purchase order 'PO#" "Lineitem"' was encountered. As checked, all data are correct including the pla

  • Visual Studio 6 SP6 bundle

    Hi, I have been trying to figure out how to install Visual Studio 6 on Windows XP for a while now. Here's what I tried so far: Bundle 1 - MS JAVA VM v5.0.2752.0 1- Copy the file "MSJAVX86.EXE" in the folder "${SYSTEMDRIVE}\Temp" 2- Run the following

  • How to make htis code work with select options???

    REPORT YTEST. TABLES: MARA,MARC,MARD,MBEW,MVKE,MAKT. DATA: BEGIN OF I_MARC OCCURS 0, MATNR LIKE MARC-MATNR, EKGRP LIKE MARC-EKGRP, PSTAT LIKE MARC-PSTAT, DISPO LIKE MARC-DISPO, BESKZ LIKE MARC-beskz, END OF I_MARC. DATA: BEGIN OF I_MARD OCCURS 0, MAT

  • Open file limit in limits.conf not being enforced

    So I am running a Arch installation without a graphical UI and Im running elasticsearch on it as its own user (elasticsearch). Since elasticsearch needs to be able to handle more than the 4066 files that seems to the be the default, I edit /etc/secur

  • Batch inputs sessions got deleted

    Dear All, We have a major issue on our SAP Production server. We have executed the report RSBDCTL2 as a background job RSBDCTL2_300 on 29th May 2010 with delete option. This has deleted all the batch input sessions that were existing in SAP Productio