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

Similar Messages

  • 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

  • Can we create materialized view on the top of another materialized view.

    Hi ,
    can we create materialized view on the top of another materialized view.
    Thanks
    Naveen

    Welcome , Just remember is not good apporch to do that since performance when MV refresh
    Please mark this thread as answered .

  • 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

  • Creating a view with a primary key

    I want to create a view with a defined primary key. I understand
    the view is created within a select statement, but do not
    understand how you would define a particular field as a primary
    key in the view. Also if your select statement attempts to build
    the view and has duplicate keys in the select result set, what
    would happen when the duplicate key is found? Would it just not
    include the duplicate key in the view?
    Thanks in advance for your help.
    -Pat

    I have a rather difficult problem with duplicate invoice numbers
    contained in unique records. In other words I have many records
    that appear as follows:
    3593, 0004009090, CUSTOMER, TAX, 20000117,014011976-01
    4411, 0004009090, CUSTOMER, TAX, 20000718,014011976-01
    The last field is invoice number '014011976-01' In my case I am
    building a flat file using UTL_FILE for loading into SAP
    Business Warehouse. In SAP I need to have Invoice number as a
    key in which case I can't have duplicate invoice numbers. All
    the SQL I have tried to date returns a large amount of records
    similar to the above records. I am selecting these records from
    4 different schemas which represent 4 different companies. I
    realize the data is the problem and that the vendor of the
    product I am working with should not allow records with
    duplicate invoice numbers, but I have to get the data loaded as
    that is what they want and are paying for. So back to my View. I
    was hoping to create a view and be able to work in the view to
    remove duplicate records prior to writing them to a file. Any
    suggestions are welcomed.
    Thanks
    -Pat

  • 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.

  • 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

  • How to create materialized  view with parameter and index ?

    Hi all,
    i am using oracle 11g.
    i want to create  parameter materialized view  with two parameter (STORED_VALUE, LOV_NAME) with  an index .
    i have below view
    CREATE OR REPLACE FORCE VIEW SR_MY_TEST(DISPLAYED_VALUE, STORED_VALUE, LOV_NAME) AS
      SELECT  DISPLAYED_VALUE , LOVVALUE.STORED_VALUE , lovname.lov_name
               FROM (SELECT T.LOV_VALUE_ID,
          T.LOV_ID,
          T.ORG_ENTITY_ID,
          T.STORED_VALUE,
          T.DISPLAYED_VALUE,
          T.ENTERPRISE_ID
         FROM MS_QS_LIST_OF_VALUES_T T) lovvalue, ms_qs_lov_names lovname
              WHERE lovvalue.lov_id = lovname.lov_id
                AND lovvalue.org_entity_id = 1
                and LOVVALUE.ENTERPRISE_ID = 100000
                AND LOVNAME.ENTERPRISE_ID = 100000;
    i want to create index on   STORED_VALUE, LOV_NAME
    Thanks
    Damby

    No.AFAIK, there's nothing called as "parameterized MV".
    Materialized View store data like tables (and not like Views). So, does it make sense when you say - "table with parameters" ?
    Could you please explain your business requirement?
    What is the purpose behind those 2 parameters?

  • Create Materialized View with Compress clause

    Hi,
    Oracle 9i R2 has an option to use compress clause while creating table, materialized view or etc. Just wanted some help on tips to be followed during creating a materilized view with compress clause and refresh the same.do i need to follow any special procedures ??? Any help greatly appreciated.
    Thanks,
    Chak.

    I read in the book that while inserting user /+append+/ otherwise table with compress will fail. I am doing materialized view refresh with fast mode and data will be inserted as per logs residing at master site.. while inserting into materialized view, do i have to setup specially since fast refresh is going to insert data into existing materialized view.
    Thanks,

  • Create material view with MATERIAL_MAINTAIN_DARK

    Hello !
    I have done a material migration program with FM MATERIAL_MAINTAIN_DARK. The program integrate the basic data, and then each view one by one.
    It works fine except with material with internal number. It creats the basic data but when i use the number generated to create the other view i get this message :
    No external number assignment possible for mat. type GENERIC MATERIALS
    I found this field in mara_ueb : KZ_MAT_RES
    But when i put X in it, it returns that i forgot mandatory data. So I tried to select the data already in MARA and MAKT, but now the message is that the material already exist ! It is true but I want to create another view.
    Here's a piece of my code to help you to understand, the commentary part is what I tried to do to resolved my problem :
      ADD 1 TO v_count.
      ADD 1 TO v_line.
      MOVE v_line TO v_line_c.
    *---MARA
      MOVE sy-mandt TO t_mara_ueb-mandt.
      MOVE 'MM01' TO t_mara_ueb-tcode.
      MOVE v_count TO t_mara_ueb-tranc.
      MOVE k_purcha TO t_mara_ueb-vpsta.
      SELECT COUNT(*) FROM t134 WHERE mtart = t_data_pur-mtart
                                   AND envop = space.
      IF sy-subrc = 0.
        TABLES : mara, makt.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
           input         = t_data_pur-matnr
        IMPORTING
          OUTPUT        = t_data_pur-matnr.
       SELECT SINGLE * FROM mara WHERE matnr = t_data_pur-matnr.
       MOVE-CORRESPONDING mara TO t_mara_ueb.
       SELECT SINGLE * FROM makt WHERE matnr = t_data_pur-matnr.
       MOVE-CORRESPONDING makt TO t_makt_ueb.
         MOVE 'X' TO t_mara_ueb-KZ_MAT_RES.
      ENDIF.
      MOVE t_data_pur-matnr TO t_mara_ueb-matnr.
      MOVE t_data_pur-mbrsh TO t_mara_ueb-mbrsh.
      MOVE t_data_pur-mtart TO t_mara_ueb-mtart.
      MOVE t_data_pur-ekwsl TO t_mara_ueb-ekwsl.
      APPEND t_mara_ueb.
    *---MARC
      MOVE sy-mandt TO t_marc_ueb-mandt.
      MOVE v_count TO t_marc_ueb-tranc.
      MOVE t_data_pur-matnr TO t_marc_ueb-matnr.
      MOVE t_data_pur-werks TO t_marc_ueb-werks.
      MOVE t_data_pur-ekgrp TO t_marc_ueb-ekgrp.
      MOVE t_data_pur-mmsta TO t_marc_ueb-mmsta.
      MOVE t_data_pur-mmstd TO t_marc_ueb-mmstd.
      MOVE t_data_pur-webaz TO t_marc_ueb-webaz.
      MOVE t_data_pur-kordb TO t_marc_ueb-kordb.
      MOVE t_data_pur-usequ TO t_marc_ueb-usequ.
      APPEND t_marc_ueb.
    *---!!! Call FUNCTION MODULE !!!
      CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'
        EXPORTING
        FLAG_MUSS_PRUEFEN               = 'X'
        SPERRMODUS                      = 'E'
        MAX_ERRORS                      = 0
         p_kz_no_warn                    = 'X'
         kz_prf                          = space
        KZ_VERW                         = 'X'
        KZ_AEND                         = 'X'
        KZ_DISPO                        = 'X'
         kz_test                         = lv_test
        NO_DATABASE_UPDATE              = ' '
         call_mode                       = ' '   "OR RMD OR space OR BAP
        CALL_MODE2                      = ' '
         user                            = sy-uname
        SUPPRESS_ARRAY_READ             = ' '
        FLG_MASS                        = ' '
        IMPORTING
         matnr_last                      = lv_matnr
         number_errors_transaction       = lv_nb_error
        TABLES
         amara_ueb                       = t_mara_ueb
         amakt_ueb                       = t_makt_ueb
         amarc_ueb                       = t_marc_ueb
         amard_ueb                       = t_mard_ueb
        AMFHM_UEB                       =
        AMARM_UEB                       =
        AMEA1_UEB                       =
         ambew_ueb                       = t_mbew_ueb
         asteu_ueb                       = t_steu_ueb
        ASTMM_UEB                       =
         amlgn_ueb                       = t_mlgn_ueb
         amlgt_ueb                       = t_mlgt_ueb
        AMPGD_UEB                       =
         ampop_ueb                       = t_mpop_ueb
        AMVEG_UEB                       =
        AMVEU_UEB                       =
         amvke_ueb                       = t_mvke_ueb
        ALTX1_UEB                       =
        AMPRW_UEB                       =
        AMFIELDRES                      =
         amerrdat                        = t_amerrdat
       EXCEPTIONS
         kstatus_empty                   = 1
         tkstatus_empty                  = 2
         t130m_error                     = 3
         internal_error                  = 4
         too_many_errors                 = 5
         update_error                    = 6
         OTHERS                          = 7.
    I really need you help !
    thank you in advance.

    OK I found the answer !
    It is because the matnr generate add 00000... before the number. So I have to add it for the other view. But it is not the case for material number define externally. And the message was not comprensive.
    *---MARA
      MOVE sy-mandt TO t_mara_ueb-mandt.
      MOVE 'MM01' TO t_mara_ueb-tcode.
      MOVE v_count TO t_mara_ueb-tranc.
      MOVE k_purcha TO t_mara_ueb-vpsta.
      SELECT COUNT(*) FROM t134 WHERE mtart = t_data_pur-mtart
                                  AND envop = space.
      IF sy-subrc = 0.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  input  = t_data_pur-matnr
             IMPORTING
                  output = t_data_pur-matnr.
      ENDIF.
      MOVE t_data_pur-matnr TO t_mara_ueb-matnr.
      MOVE t_data_pur-mbrsh TO t_mara_ueb-mbrsh.
      MOVE t_data_pur-mtart TO t_mara_ueb-mtart.
      MOVE t_data_pur-ekwsl TO t_mara_ueb-ekwsl.
      APPEND t_mara_ueb.
    *---MARC
      MOVE sy-mandt TO t_marc_ueb-mandt.
      MOVE v_count TO t_marc_ueb-tranc.
      MOVE t_data_pur-matnr TO t_marc_ueb-matnr.
      MOVE t_data_pur-werks TO t_marc_ueb-werks.
      MOVE t_data_pur-ekgrp TO t_marc_ueb-ekgrp.
      MOVE t_data_pur-mmsta TO t_marc_ueb-mmsta.
      MOVE t_data_pur-mmstd TO t_marc_ueb-mmstd.
      MOVE t_data_pur-webaz TO t_marc_ueb-webaz.
      MOVE t_data_pur-kordb TO t_marc_ueb-kordb.
      MOVE t_data_pur-usequ TO t_marc_ueb-usequ.
      APPEND t_marc_ueb.
    Edited by: Louis-Arnaud Bouquin on Mar 5, 2008 3:04 PM

  • How to create a view with a column of counts of the occurence of values

    If my table is:
    ID
    1
    2
    3
    3
    5
    5
    5
    I want to create a view with the following result:
    ID   COUNT
    1     1
    2     1
    3     2
    5     3
    How would I accomplish this?

    Sorry, my mistake. I was thinking about counting distinct events.
    I created a table with your example values:
    You should do a projection with a calculated column = 1:
    And then add this calculated column as an aggregated measure on the aggregation node:
    Result:
    Cheers,
    Fernando

  • Materialized View with Joins

    Dear Dev/DBAs,
    I have the following scenario:
    SQL> CREATE TABLE T1 (ID NUMBER(3),NAME VARCHAR2(10));
    SQL> CREATE TABLE T2 (ID NUMBER(3),NAME VARCHAR2(10));
    The T1 contains records having the ID num from 10 to 80 and the T2 having the ID from 90 to 170
    SQL> SELECT * FROM T1 JOIN ALL SELECT * FROM T2
    It give all records in the 2 tables.
    I'm planning to create a materialized view (like CREATE MATERIALIZED VIEW V_TAB REFRESH ON COMMIT AS SELECT * FROM T1 JOIN ALL SELECT * FROM T2) and it seems i can't do with the error ORA-12054, further the oracle documentation says that materialized view can only be used with a simple join.
    Do you have another solution??
    Note that the materialized views can be used to improve queries.
    Thank you in advance

    Straight from the link I posted:
    *Restrictions on Fast Refresh on Materialized Views with UNION ALL*Materialized views with the UNION ALL set operator support the REFRESH FAST option if the following conditions are satisfied:
    * The defining query must have the UNION ALL operator at the top level.
    The UNION ALL operator cannot be embedded inside a subquery, with one exception: The UNION ALL can be in a subquery in the FROM clause provided the defining query is of the form SELECT * FROM (view or subquery with UNION ALL) as in the following example:
    CREATE VIEW view_with_unionall AS
    (SELECT c.rowid crid, c.cust_id, 2 umarker
    FROM customers c WHERE c.cust_last_name = 'Smith'
    UNION ALL
    SELECT c.rowid crid, c.cust_id, 3 umarker
    FROM customers c WHERE c.cust_last_name = 'Jones');
    CREATE MATERIALIZED VIEW unionall_inside_view_mv
    REFRESH FAST ON DEMAND AS
    SELECT * FROM view_with_unionall;
    Note that the view view_with_unionall satisfies the requirements for fast refresh.
    * Each query block in the UNION ALL query must satisfy the requirements of a fast refreshable materialized view with aggregates or a fast refreshable materialized view with joins.
    The appropriate materialized view logs must be created on the tables as required for the corresponding type of fast refreshable materialized view.
    Note that the Oracle Database also allows the special case of a single table materialized view with joins only provided the ROWID column has been included in the SELECT list and in the materialized view log. This is shown in the defining query of the view view_with_unionall.
    * The SELECT list of each query must include a maintenance column, called a UNION ALL marker. The UNION ALL column must have a distinct constant numeric or string value in each UNION ALL branch. Further, the marker column must appear in the same ordinal position in the SELECT list of each query block.
    * Some features such as outer joins, insert-only aggregate materialized view queries and remote tables are not supported for materialized views with UNION ALL.
    * Partiton Change Tracking (PCT)-based refresh is not supported for UNION ALL materialized views.
    * The compatibility initialization parameter must be set to 9.2.0 or higher to create a fast refreshable materialized view with UNION ALL.

  • Help to create Materialized View that has timestamp conversion

    I need help creating materialized view with timestamp conversion between GMT to LocalTime.
    Feel free to make any comments.
    Thanks in advance.
    jon joaquino;)

    Here is one way.
    1. Alter the table hist_table and add a new column pdt_timestamp.
    2. Update the new column using the function 'new_time'
    For example,
    Update hist_table
    set pdt_timestamp = new_time(gmt_timestamp,'GMT','PDT');
    3. create a materialized view log on the table 'hist_table' using the syntax
    create materialized view log on hist_table
    with primary key, rowid, sequence;
    4. create a materialized view now using the syntax:
    (You have to specify your own storage numbers and tablespace name)
    create materialized view mview_hist_table
    pctfree 0 tablespace mymview
    storage (initial 16k next 16k pctincrease 0)
    build immediate
    refresh fast on commit
    as select uid,gmt_timestamp,pdt_timestamp
    from hist_table;
    Please test on your test instance before doing it on production. I have tested this on Oracle 10g for Windows 2000. I assumed that column 'uid' is the primary key on the table. I hope this helps.
    **********************************************************

  • 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

Maybe you are looking for