Issue with creating materialized view

Hi,
We have a select query (containing joins, aggregates and UNION ALL’s) using which we are creating materialized views. We were able to create these mat views in development environment, however when tried to run the same scripts in a higher environment the creation never completes. The higher environment has three times more data than in Dev currently.
The below operations complete well in time , but when we add “CREATE MATERIALIZED VIEW MAT_VIEW_NAME” to the select query it takes forever (we have cancelled the operation after waiting for more 1 hour)
Select count(1) from the complete Mat. View query -     takes 3.2 min to complete - the query resullts in      3,010,068 rows
Create Normal VIEW using complete Mat. View select query -     takes      3.06 sec     to complete
Create table using complete Mat. View select query     takes 5.75 min to complete - the query resullts in           3,010,068
Does anyone have an idea why this could be happening ? if you have ever faced this kind of issue, can you please provide pointers on how you were able to solve the problem. We are using Oracle 11g.
Let me know if I have to provide any other information for you to understand the issue better.
Thanks

SELECT vis.uid, findet.yr, findet.ect, vis.ind,
tm_view.col1_id, tm_view.col1_name,
tm_view.col2_id, tm_view.col2_name,
tm_view.col3_id, tm_view.col3_name,
clnt.cl_id, clnt.cl_nm,
prodparent_view.parent_cd,
prodparent_view.parent_desc,
prod_view.parent_cd,
prod_view.parent_desc,
prod_view.child_cd,
prod_view.child_desc,
SUM (value1), SUM (value2),
SUM (value3), SUM (value4),
SUM (value5), SUM (value6),
SUM (value7), SUM (value8),
SUM (value9), SUM (value10),
SUM (value11), SUM (value12)
FROM vis,
(SELECT *
FROM analytic_e,
(SELECT table_val
FROM TAB_CHECK s
WHERE s.tgt_table_nm = 'ANALYTIC'
AND s.table_val = 'ANALYTIC_E')
WHERE table_val = 'ANALYTIC_E'
UNION ALL
SELECT *
FROM analytic_o,
(SELECT switch_val
FROM tab_check s
WHERE s.tgt_table_nm = 'ANALYTIC'
AND s.switch_val = 'ANALYTIC_O')
WHERE switch_val = 'ANALYTIC_O') findet,
prod_view,
prodparent_view,
tm_view,
clnt,
(select to_number(to_char(ref_dt,'yyyy'))-1 year_agg from DATE_TABLE) tbabt
WHERE tbabt.yr = findet.yr
AND vis.cl_key = findet.cl_key
AND tm_view.hi_key = findet.hi_key
AND prod_view.child_cd = findet.prod_cd
AND clnt.cl_key = findet.cl_key
AND prodparent_view.child_cd = prod_view.parent_cd
GROUP BY vis.uid, findet.yr, findet.ect, vis.ind,
tm_view.col1_id, tm_view.col1_name,
tm_view.col2_id, tm_view.col2_name,
tm_view.col3_id, tm_view.col3_name,
clnt.cl_id, clnt.cl_nm,
prodparent_view.parent_cd
prodparent_view.parent_desc
prod_view.parent_cd
prod_view.parent_desc
prod_view.child_cd
prod_view.child_desc
Higher Environment
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 57M| 65G| | 20M (1)| 66:48:28 | | |
| 1 | HASH GROUP BY | | 57M| 65G| 73G| 20M (1)| 66:48:28 | | |
|* 2 | HASH JOIN | | 57M| 65G| | 109K (2)| 00:21:58 | | |
| 3 | TABLE ACCESS BY INDEX ROWID | HIER | 2100 | 244K| | 172 (0)| 00:00:03 | | |
|* 4 | INDEX RANGE SCAN | UK_HIER | 2100 | | | 16 (0)| 00:00:01 | | |
|* 5 | HASH JOIN | | 57M| 59G| | 109K (1)| 00:21:52 | | |
| 6 | VIEW | VW_GBF_25 | 1908 | 868K| | 2612 (1)| 00:00:32 | | |
| 7 | HASH GROUP BY | | 1908 | 141K| | 2612 (1)| 00:00:32 | | |
| 8 | VIEW | | 45107 | 3347K| | 2609 (1)| 00:00:32 | | |
| 9 | UNION-ALL | | | | | | | | |
| 10 | HASH UNIQUE | | 22518 | 1473K| 1872K| 1010 (1)| 00:00:13 | | |
|* 11 | TABLE ACCESS FULL | HIER | 22518 | 1473K| | 650 (1)| 00:00:08 | | |
| 12 | HASH UNIQUE | | 22518 | 1165K| 1512K| 947 (1)| 00:00:12 | | |
|* 13 | TABLE ACCESS FULL | HIER | 22518 | 1165K| | 650 (1)| 00:00:08 | | |
| 14 | HASH UNIQUE | | 71 | 1917 | | 652 (1)| 00:00:08 | | |
|* 15 | TABLE ACCESS FULL | HIER | 22518 | 593K| | 650 (1)| 00:00:08 | | |
|* 16 | HASH JOIN | | 64M| 38G| 4936K| 106K (1)| 00:21:16 | | |
| 17 | VIEW | | 45107 | 4404K| | 2609 (1)| 00:00:32 | | |
| 18 | UNION-ALL | | | | | | | | |
| 19 | HASH UNIQUE | | 22518 | 1473K| 1872K| 1010 (1)| 00:00:13 | | |
|* 20 | TABLE ACCESS FULL | HIER | 22518 | 1473K| | 650 (1)| 00:00:08 | | |
| 21 | HASH UNIQUE | | 22518 | 1165K| 1512K| 947 (1)| 00:00:12 | | |
|* 22 | TABLE ACCESS FULL | HIER | 22518 | 1165K| | 650 (1)| 00:00:08 | | |
| 23 | HASH UNIQUE | | 71 | 1917 | | 652 (1)| 00:00:08 | | |
|* 24 | TABLE ACCESS FULL | HIER | 22518 | 593K| | 650 (1)| 00:00:08 | | |
|* 25 | HASH JOIN | | 3021K| 1550M| 15M| 24492 (1)| 00:04:54 | | |
| 26 | PARTITION HASH ALL | | 491K| 10M| | 1059 (1)| 00:00:13 | 1 | 16 |
| 27 | MAT_VIEW ACCESS FULL | VIS | 491K| 10M| | 1059 (1)| 00:00:13 | 1 | 16 |
|* 28 | HASH JOIN | | 388K| 190M| 6056K| 12929 (1)| 00:02:36 | | |
| 29 | TABLE ACCESS FULL | CLNT | 64540 | 5294K| | 411 (1)| 00:00:05 | | |
|* 30 | HASH JOIN | | 388K| 159M| | 4072 (1)| 00:00:49 | | |
| 31 | TABLE ACCESS FULL | DATE_TABLE | 2 | 16 | | 3 (0)| 00:00:01 | | |
| 32 | VIEW | | 582K| 235M| | 4065 (1)| 00:00:49 | | |
| 33 | UNION-ALL | | | | | | | | |
| 34 | NESTED LOOPS | | 272K| 52M| | 1860 (1)| 00:00:23 | | |
|* 35 | TABLE ACCESS BY INDEX ROWID| TAB_CHECK | 1 | 46 | | 1 (0)| 00:00:01 | | |
|* 36 | INDEX UNIQUE SCAN | SYS_C0041157 | 1 | | | 0 (0)| 00:00:01 | | |
| 37 | PARTITION RANGE ALL | | 272K| 40M| | 1859 (1)| 00:00:23 | 1 |1048575|
| 38 | TABLE ACCESS FULL | ANALYTIC_E | 272K| 40M| | 1859 (1)| 00:00:23 | 1 |1048575|
| 39 | NESTED LOOPS | | 309K| 58M| | 2205 (1)| 00:00:27 | | |
|* 40 | TABLE ACCESS BY INDEX ROWID| TAB_CHECK | 1 | 46 | | 1 (0)| 00:00:01 | | |
|* 41 | INDEX UNIQUE SCAN | SYS_C0041157 | 1 | | | 0 (0)| 00:00:01 | | |
| 42 | PARTITION RANGE ALL | | 309K| 44M| | 2204 (1)| 00:00:27 | 1 |1048575|
| 43 | TABLE ACCESS FULL | ANALYTIC_O | 309K| 44M| | 2204 (1)| 00:00:27 | 1 |1048575|
Development
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1696K| 1276M| | 291K (1)| 00:58:20 | | |
| 1 | HASH GROUP BY | | 1696K| 1276M| 1325M| 291K (1)| 00:58:20 | | |
|* 2 | HASH JOIN | | 1696K| 1276M| | 9721 (2)| 00:01:57 | | |
| 3 | VIEW | | 15464 | 1132K| | 1855 (1)| 00:00:23 | | |
| 4 | UNION-ALL | | | | | | | | |
| 5 | HASH UNIQUE | | 7681 | 502K| | 618 (1)| 00:00:08 | | |
|* 6 | TABLE ACCESS FULL | HIER | 7681 | 502K| | 617 (1)| 00:00:08 | | |
| 7 | HASH UNIQUE | | 7681 | 375K| | 618 (1)| 00:00:08 | | |
|* 8 | TABLE ACCESS FULL | HIER | 7681 | 375K| | 617 (1)| 00:00:08 | | |
| 9 | HASH UNIQUE | | 102 | 2448 | | 618 (1)| 00:00:08 | | |
|* 10 | TABLE ACCESS FULL | HIER | 7681 | 180K| | 617 (1)| 00:00:08 | | |
|* 11 | HASH JOIN | | 371K| 252M| | 7847 (2)| 00:01:35 | | |
| 12 | VIEW | | 15464 | 1510K| | 1855 (1)| 00:00:23 | | |
| 13 | UNION-ALL | | | | | | | | |
| 14 | HASH UNIQUE | | 7681 | 502K| | 618 (1)| 00:00:08 | | |
|* 15 | TABLE ACCESS FULL | HIER | 7681 | 502K| | 617 (1)| 00:00:08 | | |
| 16 | HASH UNIQUE | | 7681 | 375K| | 618 (1)| 00:00:08 | | |
|* 17 | TABLE ACCESS FULL | HIER | 7681 | 375K| | 617 (1)| 00:00:08 | | |
| 18 | HASH UNIQUE | | 102 | 2448 | | 618 (1)| 00:00:08 | | |
|* 19 | TABLE ACCESS FULL | HIER | 7681 | 180K| | 617 (1)| 00:00:08 | | |
|* 20 | HASH JOIN | | 122K| 71M| | 5987 (2)| 00:01:12 | | |
|* 21 | TABLE ACCESS FULL | HIER | 7681 | 915K| | 617 (1)| 00:00:08 | | |
|* 22 | HASH JOIN | | 122K| 57M| 4512K| 5368 (2)| 00:01:05 | | |
|* 23 | HASH JOIN | | 9556 | 4395K| 3856K| 2409 (2)| 00:00:29 | | |
| 24 | TABLE ACCESS FULL | CLNT | 74426 | 2979K| | 310 (1)| 00:00:04 | | |
|* 25 | HASH JOIN | | 9556 | 4012K| | 1710 (2)| 00:00:21 | | |
| 26 | TABLE ACCESS FULL | DATE_TABLE | 1 | 7 | | 3 (0)| 00:00:01 | | |
| 27 | VIEW | | 19112 | 7894K| | 1706 (2)| 00:00:21 | | |
| 28 | UNION-ALL | | | | | | | | |
| 29 | MERGE JOIN CARTESIAN | | 19111 | 4068K| | 1701 (2)| 00:00:21 | | |
|* 30 | TABLE ACCESS FULL | TAB_CHECK | 1 | 49 | | 3 (0)| 00:00:01 | | |
| 31 | BUFFER SORT | | 248K| 40M| | 1698 (2)| 00:00:21 | | |
| 32 | PARTITION RANGE ALL| | 248K| 40M| | 1698 (2)| 00:00:21 | 1 |1048575|
| 33 | TABLE ACCESS FULL | ANALYTIC_E | 248K| 40M| | 1698 (2)| 00:00:21 | 1 |1048575|
| 34 | MERGE JOIN CARTESIAN | | 1 | 537 | | 5 (0)| 00:00:01 | | |
| 35 | PARTITION RANGE ALL | | 1 | 488 | | 2 (0)| 00:00:01 | 1 |1048575|
| 36 | TABLE ACCESS FULL | ANALYTIC_O | 1 | 488 | | 2 (0)| 00:00:01 | 1 |1048575|
| 37 | BUFFER SORT | | 1 | 49 | | 3 (0)| 00:00:01 | | |
|* 38 | TABLE ACCESS FULL | TAB_CHECK | 1 | 49 | | 3 (0)| 00:00:01 | | |
| 39 | PARTITION HASH ALL | | 810K| 16M| | 1456 (2)| 00:00:18 | 1 | 16 |
| 40 | MAT_VIEW ACCESS FULL | VIS | 810K| 16M| | 1456 (2)| 00:00:18 | 1 | 16 |
-----------------------------------------------------------------------------------------------------------------------------------------

Similar Messages

  • Issue with creating a view

    Oracle gurus,
    pls assist me to modify the following query to create my own view that will allow me to display department name of the employee assignment screen.
    People>Enter & Maintain>Assignment
    Organization
    SELECT plrl.letter_request_id letter_request_id,ads_adi_utils_pkg.decode_nls_lookup('TITLE',papf.title,plrl.business_group_id) title
    , SUBSTR(papf.first_name,1,1)||'.' init
    , papf.first_name first_name
    , papf.last_name last_name
    , hou.name organisation
    , pad.address_line1 address_line_1
    , pad.address_line2 address_line_2
    , pad.address_line3 address_line_3
    , pad.town_or_city town
    , pad.postal_code post_code
    , pav.name vacancy
    , pj.name job
    , pp.name position
    FROM per_all_people_f papf
    , per_letter_request_lines plrl
    , per_all_assignments_f paaf
    , per_addresses pad
    , per_all_vacancies pav
    , hr_all_organization_units hou
    --,     HR_ALL_ORGANIZATION_UNITS_TL                         hou1
    , per_jobs pj
    , per_all_positions pp
    WHERE paaf.person_id = papf.person_id
    AND plrl.assignment_id = paaf.assignment_id
    AND paaf.vacancy_id = pav.vacancy_id(+)
    AND papf.person_id = pad.person_id(+)
    AND pad.primary_flag(+) = 'Y'
    --AND    hou1.organization_id      = hou.organization_id(+)
    AND paaf.organization_id = hou.organization_id(+)
    AND pav.job_id = pj.job_id(+)
    AND pav.position_id = pp.position_id(+)
    AND paaf.effective_end_date = (SELECT MAX(effective_end_date)
    FROM per_all_assignments_f WHERE assignment_id = paaf.assignment_id)
    AND papf.effective_start_date = (SELECT MAX(effective_start_date)
    FROM per_all_people_f WHERE person_id = papf.person_id)
    Please help me to modify the above query so that the output must show the employee assignment organization and not the vacancy org.
    Please help

    remove the effective date conditions from your query -
    AND paaf.effective_end_date = (SELECT MAX(effective_end_date)
    FROM per_all_assignments_f WHERE assignment_id = paaf.assignment_id)
    AND papf.effective_start_date = (SELECT MAX(effective_start_date)
    FROM per_all_people_f WHERE person_id = papf.person_id)and add the below -
    AND sysdate between paaf.effective_start_date and paaf.effective_end_date
    AND sysdate between papf.effective_start_date and papf.effective_end_dateCheers,
    Vignesh

  • Creating Materialized View in Toad

    As with every new endeavor - come new questions.
    I am trying to create a materialized view via toad (first time doing this). Now - toad is great, since it provides a kind-of wizard interface. Hence, one doesn't have to completely code in the create statement, with all of the options, etc.
    Instead, in toad, one can (via the schema browser), go into the Materialized Views tab and click on create new. This opens a window with 6 tabs: Basic Info, Refresh Info, Physical Attributes, Query, Partitions & Subpartition Template.
    In the Basic Info, one can put a check mark next to some of the following options:
    -Build Deffered
    -Parallel
    -Cache
    -Logging
    -Using index
    -Allow updates
    etc.
    I have read that build deferred refers to whether or not you would like the view to be created automatically or to be deferred.
    Anyways, I tried to find Toad documentation to explain each of the options in-detail. No success. Hence, am researching each part piece by piece.
    But - here is my question:
    In the Query tab, we are asked to specify a query. I am assuming that the query does not have to be a full query, beginning with CREATE MATERIALIZED VIEW mv_table1 REFRESH FAST etc...
    Since in this 'wizard', we are providing the MV name at the top of the dialog box, we are checking the 'options' in the other tabs, etc.
    And so, I assumed that the query should merely be a select query in the window mentioned above.
    So I entered the following:
    select * from table1@remote_db;
    When I go to verify the syntax, I get the error message: ORA_00911: invalid character. It seems to be pointing to my db_link (remote_db). I have been using this link throughout many places, w/o any problems.
    Has anyone created a MV in toad before? Any links to good toad documentation would be helpful as well.
    Thanks.

    (This is fun... ;))
    For anyone endeavoring this in the future, below I have attached the prerequisites required in order to create a materialized view (can also be found @ http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_6002.htm):
    Prerequisites
    The privileges required to create a materialized view should be granted directly rather than through a role.
    To create a materialized view in your own schema:
    You must have been granted the CREATE MATERIALIZED VIEW system privilege and either the CREATE TABLE or CREATE ANY TABLE system privilege.
    You must also have access to any master tables of the materialized view that you do not own, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a materialized view in another user's schema:
    You must have the CREATE ANY MATERIALIZED VIEW system privilege.
    The owner of the materialized view must have the CREATE TABLE system privilege. The owner must also have access to any master tables of the materialized view that the schema owner does not own (for example, if the master tables are on a remote database) and to any materialized view logs defined on those master tables, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a refresh-on-commit materialized view (ON COMMIT REFRESH clause), in addition to the preceding privileges, you must have the ON COMMIT REFRESH object privilege on any master tables that you do not own or you must have the ON COMMIT REFRESH system privilege.
    To create the materialized view with query rewrite enabled, in addition to the preceding privileges:
    If the schema owner does not own the master tables, then the schema owner must have the GLOBAL QUERY REWRITE privilege or the QUERY REWRITE object privilege on each table outside the schema.
    If you are defining the materialized view on a prebuilt container (ON PREBUILT TABLE clause), then you must have the SELECT privilege WITH GRANT OPTION on the container table.
    The user whose schema contains the materialized view must have sufficient quota in the target tablespace to store the master table and index of the materialized view or must have the UNLIMITED TABLESPACE system privilege.
    When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.

  • Create materialized view log with rowid hangs indefinitely..

    Hi
    create materialized view log on advice_note with rowid;
    This stmt hangs indefinitely...
    Help needed in resolving this issue
    Rp

    i have resolved the issue myself.
    Found out the sessions that are locking the object , killed all those sessions & pids.
    Rp

  • How to CREATE MATERIALIZED VIEW LOG (MV fast refresh) with some JOINS

    Hi @ all,
    i'm trying to create a MATERIALIZED VIEW LOG for a fast refresh of a MATERIALIZED VIEW.
    It works fine with a simple Request in the MATERIALIZED VIEW:
    CREATE MATERIALIZED VIEW MV_ZOTD43_P
    TABLESPACE GDII
    BUILD IMMEDIATE
    REFRESH FORCE AS
    SELECT * FROM ZOTD43_P;
    COMMIT;
    CREATE MATERIALIZED VIEW LOG ON ZOTD43_P
    TABLESPACE "GDII"
    WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
    call DBMS_MVIEW.REFRESH('MV_ZOTD43_P', 'f');
    But when I use a complex SQL-Request with some JOINS (one of the Table with spatial Data) in the MATERIALIZED VIEW, I get an error:
    CREATE MATERIALIZED VIEW MV_TEST
    TABLESPACE GDII
    BUILD IMMEDIATE
    REFRESH FORCE AS
    SELECT lptd04_p.sst_nr AS sst_nr,
    lptd03_p.aaaa AS aaaa,
    lptd04_geom.geom as geom
    FROM lptd04_p lptd04_p
    JOIN lptd01_p lptd01_p ON lptd01_p.cre_nr = lptd04_p.sst_nr
    JOIN lptd04_geom ON lptd04_geom.sst_nr = lptd04_p.sst_nr
    JOIN lptd03_p lptd03_p ON lptd03_p.lief_nr = lptd04_p.lief_nr;
    COMMIT;
    CREATE MATERIALIZED VIEW LOG ON LPTD04_P
    TABLESPACE "GDII"
    WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
    call DBMS_MVIEW.REFRESH('MV_TEST', 'f');
    Error report:
    SQL Error: ORA-12004: REFRESH FAST kann für Materialized View "GDI"."MV_GDI_SST_STAMM" nicht benutzt werden
    ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2255
    ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2461
    ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2430
    ORA-06512: in Zeile 1
    12004. 00000 - "REFRESH FAST cannot be used for materialized view \"%s\".\"%s\""
    *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.
    Am I doing something wrong or is it not possible CREATE MATERIALIZED VIEW LOG when the MATERIALIZED VIEW got some JOINS?
    Regards,
    Greq

    Thanks for the link Alessandro ,
    the error seems something to do with the Column-Type SDO_GEOMETRY, so
    i create a new thread in the Spatial Discussion forum:
    FAST REFRESHing of Oracle Materialized Views containing SDO_GEOMETRY column
    Regards,
    Greq

  • Create Materialized View with GROUP BY

    I have a table
    treecluster NUMBER(3)
    treenumber NUMBER(3)
    treedate DATE
    nestnumber NUMBER(3)
    eggs NUMBER(3)
    nestlings NUMBER(3)
    fledglings NUMBER(3)
    nestfate VARCHAR2(10)
    nestfailurecode NUMBER(2)
    I want to group the data by treecluster, treenumber, year, and nest number and get a max eggs, nestlings, fledglings. I am doing this with the following:
    SELECT treecluster, treenumber, to_char(nestchecksdate, 'YYYY'), nestnumber,
    max(eggs), max(nestlings), max(fledglings)
    FROM nestchecks
    GROUP BY treecluster, treenumber, to_char(nestchecksdate, 'YYYY'), nestnumber;
    This works fine.
    The last record for a year has a nestfate and nestfailurecode value.
    I need to group all information and then also get the nestfate and nestfailurecode for the year. How do I go about getting this information?
    I am really trying to create a summary materialized view based on a data table so the select I am trying to craft would be a part of a create materialized view as SELECT...
    so I want to be able to group the info and add in the nestfate and failurecode in one step.
    Thanks!

    try this:
    SQL> select * from table_tree;
    TREECLUSTER TREENUMBER NESTCHECK NESTNUMBER       EGGS  NESTLINGS FLEDGLINGS NESTFATE   NESTFAILURECODE
              4        167 17-MAY-00          2          0          0
              4        167 24-MAY-00          2          3          0
              4        167 30-MAY-00          2          3          0
              4        167 12-JUN-00          2          0          1            FAILURE                  2
    select a.treecluster, a.treenumber, to_char(a.nestyear,'YYYY') nestyear,
           a.nestnumber, a.eggs, a.nestlings, a.fledglings, a.nestfate, a.nestfailurecode
    from   (select max(treecluster) treecluster, max(treenumber) treenumber,
                   max(nestchecksdate) nestyear,
                   max(nestnumber) nestnumber, max(eggs) eggs, max(nestlings) nestlings,
                   nvl(max(FLEDGLINGS),0) FLEDGLINGS, max(NESTFATE) NESTFATE,
                   max(nestfailurecode) nestfailurecode
            from table_tree) a
    TREECLUSTER TREENUMBER NEST NESTNUMBER       EGGS  NESTLINGS FLEDGLINGS NESTFATE   NESTFAILURECODE
              4        167 2000          2          3          1          0 FAILURE                  2hope this helps

  • Create materialized view with ora-12054 error

    Oracle 10g R2 on AIX 5.3L
    I create a script (with help of EM) for a materilaized view
    CREATE MATERIALIZED VIEW "BAANDB"."R2_MV"
    TABLESPACE "USERS" NOLOGGING STORAGE ( INITIAL 128K) USING INDEX TABLESPACE "BAANIDX" STORAGE ( INITIAL 256K)
    REFRESH FORCE ON COMMIT
    ENABLE QUERY REWRITE AS
    SELECT CM.ROWID c_rid, PC.ROWID p_rid, CM."T$CWOC", "T$EMNO", CM."T$NAMA", CM."T$EDTE", PC."T$PERI", PC."T$QUAN", PC."T$YEAR", PC."T$RGDT" From BAANDB.TTPPPC235201 PC RIGHT OUTER JOIN BAANDB.TTCCOM001201 CM Using (T$EMNO)
    but I got error
    ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    acooding to the oerr
    // *Cause:  The materialized view did not satisfy conditions for refresh at
    // commit time.
    // *Action: Specify only valid options.
    what dose it mean? both my master tables are not IOT and are locale ones. It seems that only changing to ON DEMAND works. If I use the "REFRESH FORCE START ..NEXT", it also failed.
    I have created the materalized view logs with rowid on each master table. I think my script met every prequirement of ON COMMIT.
    table owner has "on commit refresh" privilege

    After googling on line, someone mentioned that for "ON COMMIT" on join tables, we have to use th old OUTER JOINT syntax (+) on WHERE. The new "outer joint" in FROM clause won't work.
    I tested it, it seemed to be true.

  • Creating Materialized View with the Distinct key word

    Hi
    I need help to create Materialized View with the Distinct key word.
    my query is
    select distinct col1, col2 from t1;
    is there any alternate of DISTINCT because I can not refresh the MV as fast on demand if I am using it and Fast on Demand is a must for me.

    hi
    check out this link
    http://download-west.oracle.com/docs/cd/B12037_01/server.101/b10736/basicmv.htm#i1007299
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/intro.htm#sthref183
    hope this helps
    CHeers

  • Create materialized view with specific column sizes

    Hi all,
    I'm trying to create a materialized view with a specific a column size. Something like
    create materialized view test_mv
    refresh force on demand
    as
    select id,
           cast(my_compound_field as nvarchar2(50))
    from ( select id,
                  field1 || field2 my_compound_field
           from   my_table);But Oracle seems to ignore the cast and takes the maximum size it finds for field1 || field2 in the select query. The resulting table has a column nvarchar2(44) instead of nvarchar2(50).
    This can give a problem when the view is refreshed... there could be new data that exceeds the current size, i.e. where length(field1 || field2) > 44.
    How can I override the column size of a field in a materialized view?
    Edit: Some additional info to clarify my case:
    field1 and field2 are defined as nvarchar2(25). field1 || field2 can theoretically have a length of 50, but there is currently no data in my table that results in that length, the max is 44. I am afraid that there will be data in the future that exceeds 44, resulting in an error when the MV is refreshed!
    Edited by: Pleiadian on Jan 25, 2011 2:06 PM

    Cannot reproduce what you are saying is happening.
    SQL> create table t (a nvarchar2(50), b nvarchar2(50));
    Table created.
    SQL> create materialized view tmv as
      2  select a, b, a || b c from t;
    Materialized view created.
    SQL> desc tmv
    Name                                      Null?    Type
    A                                                  NVARCHAR2(50)
    B                                                  NVARCHAR2(50)
    C                                                  NVARCHAR2(100)
    SQL> drop materialized view tmv;
    Materialized view dropped.
    SQL> create materialized view tmv as
      2  select a, b, substr(a || b, 1, 10) c from t;
    Materialized view created.
    SQL> desc tmv
    Name                                      Null?    Type
    A                                                  NVARCHAR2(50)
    B                                                  NVARCHAR2(50)
    C                                                  NVARCHAR2(10)
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    SQL>Edited by: 3360 on Jan 25, 2011 8:10 AM
    And with data
    SQL> insert into t values ('3123423423143hhshgvcdcvw', 'ydgeew  gdfwe   dfefde  wfjjjjjjj');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> desc tmv
    Name                                      Null?    Type
    A                                                  NVARCHAR2(50)
    B                                                  NVARCHAR2(50)
    C                                                  NVARCHAR2(10)
    SQL> select * from tmv;
    A
    B                                                  C
    3123423423143hhshgvcdcvw
    ydgeew  gdfwe   dfefde  wfjjjjjjj                      3123423423

  • Creating materialized view with variables - help

    Greetings,
    I want to create an materialized view (MV) from the external public db link. Below is my full query:
    CREATE MATERIALIZED VIEW PROJECTS_MV
    REFRESH WITH ROWID
    AS
    SELECT prj.Project_id, prj.desc,
    prj.parent_project_id, f_year, f_month
    FROM sysadm.prj@EFUYEEDW_DB_LINK.MSDB prj
    WHERE prj.pf_scenario_id = '708KDD'
    AND prj.ph_id = 'SHAREDP'
    AND f_year = (SELECT EXTRACT(year FROM current_DATE) FROM dual)
    AND f_month = (SELECT EXTRACT(month FROM current_DATE) FROM dual)
    Question: In the query there are two variables that capture the month and year and requery it. Does the data get updated automatically when a new month or new year changes?
    If there is a change, how would I change so it would update the data accordingly?
    Thanks for your help
    john9569

    Hi Christian,
    Thanks for your response. Your codes return the date as 01-JAN-09 which is not what I'm looking for. Maybe my question is not clear.
    So far, the MV is executed correctly what I want. My concern is when it updates the MV, does it get the new data (f_month & f_year) when the MV is updated automatically?
    Other words, the MV is updated nightly to get the incremental data from the db link. Once it passes to the new month, I am not sure how this MV handles since the f_month is now changed to differrent number.
    Thanks for your help.
    Bests,
    John9569

  • Error Creating Materialized View With a Job

    Oracle 9ir2
    I've created a job like this in a java class:
    ...Java Code ...
    cs = conn.prepareCall ("DECLARE v_job NUMBER; BEGIN DBMS_JOB.SUBMIT(v_job,'begin CTH_REGENERA_VM; end;', TRUNC(SYSDATE+1) + (3/24)); END;");
    ...Java Code ...
    The Procedure called in the Job:
    CREATE OR REPLACE PROCEDURE CTH_REGENERA_VM
         AUTHID CURRENT_USER IS
         existe NUMBER(1);
         cur BINARY_INTEGER := DBMS_SQL.OPEN_CURSOR;
         fdbk BINARY_INTEGER;
    BEGIN
         SELECT count(*) INTO existe FROM user_mviews WHERE mview_name = 'CTH_PRESENTA_A_VM';
         IF existe > 0 THEN
              DBMS_SQL.PARSE(cur, 'DROP MATERIALIZED VIEW CTH_PRESENTA_A_VM', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
              INSERT INTO CTH_HISTORIAL VALUES('ELIMINADA VM CTH_PRESENTA_A_VM', SYSDATE);
              COMMIT;
         END IF;
         DBMS_SQL.PARSE(cur, 'CREATE MATERIALIZED VIEW CTH_PRESENTA_A_VM
         TABLESPACE DAT1_CTH
         STORAGE(INITIAL 16M NEXT 8M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)
                   XMLTYPE XML STORE AS CLOB (           TABLESPACE DAT1_CTH
                   STORAGE(INITIAL 16M NEXT 8M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0))
         AS select FICHA, XML,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_a'') as MUNICIPIO,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_c'') as CALIFICACION,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_b'') as PROVINCIA,
         extractvalue(xml, ''/FICHE/Encab_tem�tico_de_materia_a[1]'') as MATERIA,
         extractvalue(xml, ''/FICHE/Fecha_cronol�gica_b[1]'') as FECHA,
         extractvalue(xml, ''/FICHE/Datos_matem�ticos_a[1]'') as ESCALA
         from cth_xmltable', DBMS_SQL.NATIVE);
         INSERT INTO CTH_HISTORIAL VALUES('ASIGNO EL PARSE DE MATERIALIZED', SYSDATE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('EJECUTO EL PARSE DE MATERIALIZED', SYSDATE);
         INSERT INTO CTH_HISTORIAL VALUES('CREADA VM CTH_PRESENTA_A_VM', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_INDEX1
         ON CTH_PRESENTA_A_VM(XML)
         INDEXTYPE IS CTXSYS.CONTEXT
         PARAMETERS (''storage cth section group ctxsys.auto_section_group'')', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE ORACLE TEXT CTH_INDEX1', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_IDX_MUNICIPIO3
              ON CTH_PRESENTA_A_VM(UPPER(MUNICIPIO))
              TABLESPACE IDX1_CTH
              STORAGE (INITIAL 1M NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE CTH_IDX_MUNICIPIO2', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_IDX_FICHA2
         ON CTH_PRESENTA_A_VM
         (FICHA)
         TABLESPACE IDX1_CTH
         STORAGE(INITIAL 1M NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE CTH_IDX_FICHA2', SYSDATE);
         DBMS_SQL.CLOSE_CURSOR(cur);
    COMMIT;
    END;
    I got always an error in the created materialized view. If I call the procedure with SQL Plus, it run ok. The user
    has CTXAPP, DBA roles, so I supouse it is not a privileges problem. I also tried to create a simple materialized view or a table, and always got an error ora-12011
    Thanks in advance.

    If I call the procedure with SQL Plus, it run ok. Are you using the same user to run it in SQL*Plus as runs it from Java.
    The normal reason for procedures to fail like this is privileges. Particularly, we cannot run procedures using privileges we have been granted through roles.
    The user has CTXAPP, DBA roles, so I supouse it is not a privileges problem. Try granting the system privilege CREATE MATERIALIZED VIEW to the user and see what happens.
    I drop the materialized and create again, cause it's the fastest way I've found. With a DBMS_MVIEW.REFRESH is too slow.I find that surprising as drop & create has to do all the work that a refresh has to do plus some more - maybe it's something to do with XML. Did you try adding a snapshot log and going for FAST? I don't know whwther the XML procesing would render the view complex - have you explained it?
    Cheers, APC

  • Create materialized View fails with "table or view does not exist"

    DB: 10.2.0.4
    OS: Win 2003
    Hi,
    Here in my tests, i have 2 databases (A(source) and B(backup)), and i am trying to create an mview in database B to replicate data from one test table from database A, only for test purpose. I'm getting the error "table or view does not exist" when i try to create a mview with REFRESH FAST. Here is my code:
    CREATE MATERIALIZED VIEW TESTES.TAB_TESTES_REPLIC_MVIEW_02
    REFRESH FAST
    START WITH TO_DATE('21/02/2012 18:50:00', 'DD/MM/YYYY HH24:MI:SS')
    NEXT SYSDATE + 1/24/60
    WITH PRIMARY KEY
    AS SELECT REGISTRO1,
    REGISTRO2
    FROM TESTES.TAB_TESTES_REPLIC_MVIEW_02@DB_LINK_ORA10;
    The dblink is workig fine(dblink user has select privilege on TESTES.TAB_TESTES_REPLIC_MVIEW_02), and i have created the mview log on database A.
    Where is my mistake.
    Thanks a lot.
    Edited by: Fabricio_Jorge on 21/02/2012 19:06

    I found the solution.
    I had to grant SELECT on the mview log. The name is avaiable in DBA_MVIEW_LOGS

  • Error on creating Materialized view.

    Hi,
    I don't understand why it happens...
    When I tried to creating materialized view, it shows a error "ORA-01013: User requested cancel of current operation".
    I don't understand why it happens. I just waited it successfully created. But I didn't press any button.
    Does it matter of size of joining table? I had same issue before. At that time I just removed some tables from the joining condition, this error was gone.
    But at this time, I cannot exclude any other tables the select statement
    Can anyone help me this issue, please?

    Hi,
    11g ( 11.2.0.3 ) has a problem with materialized views based on ROWID, resulting in the problem you mentioned.
    A workaround is creating the MV's based on primary keyl.
    There is also a patch available on MOS, to solve the problem ( thanks to a very long SR from me :-) )
    It is known as bug 13657605 and the patch for it has the same number.
    Remember to read the README, as this patch is only for 11.2.0.3 !!
    Cheers
    FJFranken

  • Problems in creating Materialized View from 10g R2  to 11g

    Hi,
    We have two databases in 10g Release 2. These databases are on two different servers and we use
    Materialized views to replicate data between these servers. We are currently using 64 bit version of
    oracle 10g release 2 for LINUX.
    Oracle Database 10g Release 10.2.0.1.0 - 64 bit Production
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    We use CENTOS 5 - 64 bit edition
    We upgraded one of the databases to 11g (We exported the data from old database and
    imported it in new database) . Then we tried to create a Materialized view with incremental refresh
    on it where the base table is in the second Oracle 10g database.
    The problem is that it is not letting us create the view with FAST Refresh. It kept on giving ORA-12028
    error. We tried different remedies suggested on forums like creating a view with ROWID, but still it
    continued giving us the same error. We also synchronized the characterset of Oracle 10g and Oracle 11g
    installations but still it did not work.
    Our base table size is pretty large (over 10 Million records) and if we do a full refresh, it takes hours to
    refresh it.
    Without incremental refresh, we will not be able to fucntion, and to upgrade both database simultaneously
    we will need a large down-time which also we can not afford.
    Please advise what should we do.
    Best Regards
    Madhup
    Edited by: Madhup on Mar 2, 2009 10:45 AM

    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

  • Hi experts pls help me with this materialized view refresh time!!!

    Hi Expeerts ,
    Please clarify my doubt about this materialized view code
    [\n]
    CREATE MATERIALIZED VIEW SCHEMANAME.products_mv
    REFRESH WITH ROWID
    AS SELECT * from VIEW_TABLE@DATAOPPB;
    [n]
    Here i am creating a materialized view named products_mv of the view_table present in the remote server.Can anyone tell me when will my table product_mv will get refreshed if i follow this code.As what i read from the books is that the refresh period is implicit and is carried out by the database implicitly.so can u tell me suppose i insert 2 new records into my view_table when will this record get updated into my product_mv table.
    I cant use primary key approach so this is the approach i am following .Kindly help me in understanding when will refresh of records occur in the materialized view product_mv...Pls help
    regards
    debashis

    Hi Justin ,
    Yes, my database can reasonably schedule other jobs too .Its not an issue.
    Actually what i meant "fine in all aspects" is that will the matrerialized view will get refreshed w.r.t the documetum_v table present in my remote server.This is all i need to refresh my materialized view .
    I queries the DBA_JOBS table .I could see the following result i have pasted below:-
    [\n]
    NLS_ENV
    MISC_ENV INSTANCE
    dbms_refresh.refresh('"WORKFLOW"."PRODUCTS_MV2"');
    JOB LOG_USER PRIV_USER
    SCHEMA_USER LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE
    NEXT_SEC TOTAL_TIME B
    INTERVAL
    FAILURES
    WHAT
    [n]
    here WORKFLOW"."PRODUCTS_MV2 is the materialized view i have created.So can u tell me that whether we can predict our refresh part is functioning fine from this data.If so how?
    Actually i am asking u in details as i dont have much exposure to materialized view .I am using it for the very first time.
    Regds
    debashis

Maybe you are looking for

  • Wireless not working on my MacBook pro, but works on iPhone and other MBP?!

    So I just got my new 15" MBP a few weeks ago. I have wireless Internet in my apartment. Just today I came home to use my computer, and I kept getting errors..... First "cannot connect to the internet". Then I had to enter my network password... Connn

  • Adjustment Brush Shapes

    It would be handy to be able to draw out a shape like an spline shape (as in LightZone) with edit points rather than always have to paint things in. I find the auto mask handy but not that accurate and quite a fiddle to go back around edges with a li

  • Iphone 4 and itunes syncing issues

    Not sure if this is an itunes issue or iphone4 + itunes issue So got the new iphone4 and was able to activate, restore backup and sync additional song and videos. After the second or third sync, Itunes started to crash my windows xp when syncing star

  • Email id validation regexp

    Hello all, Can any body please help me in writing a reg exp for email id validation that would cover all possibilities of validating a email id? I had tried searching few on net but some test cases for the same faild. thanks in advance Aniruddha

  • How to change the language in BIOS settings?

    I'm set the password on the L100 on Russian language, and when I switch on the computer and type right password it tells that password invalid, I think that I need to switch language, I try press alt-shift and ctrl-shift, but it doesn't work! How I c