Number Precision in Materialized View

Hey,
I have created several materialized views with multiple fields of data type number. I would like to have those number fields created with max length 5 and precision 0 (no decimal places). I am thinking that each of those database fields will then appear as NUMBER(5,0) in the database, maybe I am wrong on that.
How can I code that into my select statement for which the materialized is created?
Thanks

Todd gives a better suggestion.
I could be wrong, but I believe views in general pull their datatypes from their base sources. Therefore if you want your materialized view datatypes to be NUMBER(5,0) you will have to alter your base tables as such.
Otherwise, if you don't care about the datatype just the value, then in the select part of your materialized view you could use substr and possibly instr to get the length of five you desire and convert back to a number.
Message was edited by:
splazm

Similar Messages

  • Refreshing materialized view

    I have some question,
    1. anyone have scripts to compile, refresh and analyze all mview in a schema?
    2. how do we now mview refresh path?
    Thanks in advance.

    HI,
    May be some table of urs would have got altered..
    And as ur using inline views the problem may be ur using the inline views.
    Say for Ex
    CREATE TABLE mviewex (a NUMBER(1))
    CREATE MATERIALIZED VIEW mviewtest
    REFRESH COMPLETE ON DEMAND
    AS SELECT A FROM (SELECT a FROM mviewex)
    SELECT * FROM mviewtest
    A
    2
    3
    1
    4
    SQLWKS> EXECUTE DBMS_MVIEW.REFRESH('MVIEWTEST');
    Statement processed.
    ------now i alter the table-----------
    ALTER TABLE mviewex MODIFY(a NUMBER(3))
    INSERT INTO mviewex VALUES(447)
    INSERT INTO mviewex VALUES(444)
    INSERT INTO mviewex VALUES(445)
    SQLWKS> EXECUTE DBMS_MVIEW.REFRESH('MVIEWTEST');
    ORA-12008: error in snapshot refresh path
    ORA-01438: value larger than specified precision allows for this column
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 617
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 674
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 654
    ORA-06512: at line 2
    may be u have to drop ur snapshot and recreate it again.
    ======same works fine if i have mview some thing like this
    CREATE MATERIALIZED VIEW mviewtest
    REFRESH COMPLETE ON DEMAND
    AS SELECT A FROM mviewex
    rgds
    srinivas

  • Adding a field to materialized view

    I have a materialized view called DEVICE which gets it's data from a table called device in another database (asset3). A new field was added to the device table in the asset3 database. In order to add that field to the materialized view, will I need to drop the materialized view and recreate it or can I run an alter command to add the field?
    SQL> select MVIEW_NAME,QUERY from DBA_MVIEWS where OWNER='DWH' and MVIEW_NAME='DEVICE';
    MVIEW_NAME
    QUERY
    DEVICE
    select * from device@asset3Thanks
    Ravi

    You have to recreate materialized Views
    Example(REFRESH FAST ON COMMIT):
    SQL> CREATE MATERIALIZED VIEW LOG ON B with rowid;
    SQL> CREATE MATERIALIZED VIEW MV_B REFRESH FAST ON COMMIT with rowid AS select * from B;
    SQL> alter table B add k number;
    SQL> ALTER MATERIALIZED VIEW LOG ON B add (k);
    SQL> drop MATERIALIZED VIEW MV_B;
    SQ> CREATE MATERIALIZED VIEW MV_B REFRESH FAST ON COMMIT with rowid AS select * from B;Edited by: Surachart (HunterX) on Jun 17, 2009 11:11 PM

  • Materialized Views/Reporting Best Practice

    Hi,
    We have a number of complex materialized views (joining many tables) that are rebuilt every night by doing a full refresh (RERESH FORCE ON DEMAND). The views take a few hours to refresh and I have a concern that they will become slower over time as more data is added into the underlying tables.
    Does anyone have any advice on other ways to achieve the rebuilds other that doing a full refresh? I would ideally like to refresh on commit, but as they are complex it won't allow that.
    Regards
    Paul

    Have you tried "MATERIALIZED VIEW LOG"
    For more info you can refer..
    http://docs.oracle.com/cd/E11882_01/server.112/e25554/toc.htm

  • Recieving ORA-01722 invalid number error while creating a materialized view

    Hi,
    I am receiving a ORA-01722 invalid number error while creating a materialized view. when run the select statement of the view i don't get any error, but when i use the same select statement to create a materialized view i receive this error. Could any please help in resolving this error. Here is the code i am using to create a materialized view.
    CREATE MATERIALIZED VIEW MV_EBS_CH_CLOSED
    REFRESH FORCE ON DEMAND
    AS
    SELECT DISTINCT kr.request_id, org.org_unit_name,
    ebs_ch_ticket_type (kr.request_id) ticket_type,
    DECODE
    (kr.status_code,
    'CLOSED_SUCCESS', kr.last_update_date,
    'IN_PROGRESS', (SELECT MAX (start_time)
    FROM ebs_ch_datastore ecd1
    WHERE kr.request_id = ecd1.request_id
    AND workflow_step_name =
    'Final BA Review and Deployment Exit Criteria')
    ) closed_date,
    substr(krhd.visible_parameter12,1,10) siebel_start_date,
    kr.creation_date itg_start_date
    FROM kcrt_requests kr,
    kcrt_request_types krt,
    kcrt_req_header_details krhd, kcrt_request_details krd1,
    (SELECT koum.user_id user_id,
    DECODE (koup.org_unit_name,
    'IT Implementations', 'CHS - Service Management BA',
    koup.org_unit_name
    ) org_unit_name
    FROM krsc_org_unit_members koum, krsc_org_units koup
    WHERE 1 = 1
    AND 'Y' = koup.enabled_flag
    AND koum.org_unit_id = koup.org_unit_id
    AND EXISTS (
    SELECT 'X'
    FROM krsc_org_units kouc
    WHERE koup.org_unit_id = kouc.org_unit_id
    START WITH kouc.parent_org_unit_id =
    ANY (SELECT org_unit_id
    FROM krsc_org_units krsc_org_units1
    WHERE 'Clearinghouse' =
    org_unit_name)
    CONNECT BY kouc.parent_org_unit_id =
    PRIOR kouc.org_unit_id)
    UNION
    SELECT kou.manager_id user_id,
    DECODE
    (kou.org_unit_name,
    'IT Implementations', 'CHS - Service Management BA',
    kou.org_unit_name
    ) org_unit_name
    FROM krsc_org_units kou
    WHERE 'Y' = kou.enabled_flag
    START WITH kou.parent_org_unit_id =
    (SELECT org_unit_id
    FROM krsc_org_units krsc_org_units2
    WHERE 'Clearinghouse' = org_unit_name)
    CONNECT BY kou.parent_org_unit_id = PRIOR kou.org_unit_id) org
    WHERE krt.request_type_id = kr.request_type_id
    AND krt.request_type_name IN ('Bug Fix', 'IT Enhancement')
    and kr.REQUEST_ID = krd1.request_id
    and krd1.batch_number = 1
    AND kr.request_id = krhd.request_id
    AND org.user_id in (krd1.parameter4, krd1.parameter5, krd1.parameter7)
    AND ( 'CLOSED_SUCCESS' = kr.status_code
    OR 'IN_PROGRESS' = kr.status_code
    AND kr.request_id IN (
    SELECT request_id
    FROM (SELECT DISTINCT request_id,
    MAX
    (start_time)
    closed_date
    FROM ebs_ch_datastore
    WHERE 'Final BA Review and Deployment Exit Criteria' =
    workflow_step_name
    GROUP BY request_id))
    Thanks,
    Shaik Mohiuddin

    This error occurs when you try to create a materialized view , but if you run the sql the results are perfectly fine. Well it happend to me also and to fix this I made sure all the coulmns have the same data type which are used in joins or in where clause.
    use
    where
    to_number(col1)=to_number(col2) and to_number(col3)=to_number(col4)
    hope this helps..

  • Materialized Views: how can I find the number of updates, inserts, delete

    We are using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod.
    In a materialized view, with fast incremental refresh, done after every 5 minutes automatically, I want to store in a logging table the number of rows inserted,updated and deleted in the materialized view by that refresh.
    One option is to create a job that should read the materialized view log table just before the refresh and store the required information in the logging table. But this information may not be accurate.
    Is there any other way to collect this information for each refresh?

    Use auditing, or an before insert/update/delete trigger, that updates a counter
    I hate myself for giving this advice, because it will bring you problems, with the MV update/refresh speed, table lock contention on the log-table....
    Be carefull !!
    Why not use auditing on the source table and why does anyone wants to know the number of changes??
    Regards
    FJFranken

  • Materialized views on prebuilt tables - query rewrite

    Hi Everyone,
    I am currently counting on implementing the query rewrite functionality via materialized views to leverage existing aggregated tables.
    Goal*: to use aggregate-awareness for our queries
    How*: by creating views on existing aggregates loaded via ETL (+CREATE MATERIALIZED VIEW xxx on ON PREBUILT TABLE ENABLE QUERY REWRITE+)
    Advantage*: leverage oracle functionalities + render logical model simpler (no aggregates)
    Disadvantage*: existing ETL's need to be written as SQL in view creation statement --> aggregation rule exists twice (once on db, once in ETL)
    Issue*: Certain ETL's are quite complex via lookups, functions, ... --> might create overy complex SQLs in view creation statements
    My question: is there a way around the issue described? (I'm assuming the SQL in the view creation is necessary for oracle to know when an aggregate can be used)
    Best practices & shared experiences are welcome as well of course
    Kind regards,
    Peter

    streefpo wrote:
    I'm still in the process of testing, but the drops should not be necessary.
    Remember: The materialized view is nothing but a definition - the table itself continues to exist as before.
    So as long as the definition doesn't change (added column, changed calculation, ...), the materialized view doesn't need to be re-created. (as the data is not maintained by Oracle)Thanks for reminding me but if you find a documented approach I will be waiting because this was the basis of my argument from the beginning.
    SQL> select * from v$version ;
    BANNER                                                                                                                                                                    
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                                                                                    
    PL/SQL Release 11.2.0.1.0 - Production                                                                                                                                    
    CORE     11.2.0.1.0     Production                                                                                                                                                
    TNS for Linux: Version 11.2.0.1.0 - Production                                                                                                                            
    NLSRTL Version 11.2.0.1.0 - Production                                                                                                                                    
    SQL> desc employees
    Name                                                                                            Null?    Type
    EMPLOYEE_ID                                                                                     NOT NULL NUMBER(6)
    FIRST_NAME                                                                                               VARCHAR2(20)
    LAST_NAME                                                                                       NOT NULL VARCHAR2(25)
    EMAIL                                                                                           NOT NULL VARCHAR2(25)
    PHONE_NUMBER                                                                                             VARCHAR2(20)
    HIRE_DATE                                                                                       NOT NULL DATE
    JOB_ID                                                                                          NOT NULL VARCHAR2(10)
    SALARY                                                                                                   NUMBER(8,2)
    COMMISSION_PCT                                                                                           NUMBER(2,2)
    MANAGER_ID                                                                                               NUMBER(6)
    DEPARTMENT_ID                                                                                            NUMBER(4)
    SQL> select count(*) from employees ;
      COUNT(*)                                                                                                                                                                
           107                                                                                                                                                                
    SQL> create table mv_table nologging as select department_id, sum(salary) as totalsal from employees group by department_id ;
    Table created.
    SQL> desc mv_table
    Name                                                                                            Null?    Type
    DEPARTMENT_ID                                                                                            NUMBER(4)
    TOTALSAL                                                                                                 NUMBER
    SQL> select count(*) from mv_table ;
      COUNT(*)                                                                                                                                                                
            12                                                                                                                                                                
    SQL> create materialized view mv_table on prebuilt table with reduced precision enable query rewrite as select department_id, sum(salary) as totalsal from employees group by department_id ;
    Materialized view created.
    SQL> select count(*) from mv_table ;
      COUNT(*)                                                                                                                                                                
            12                                                                                                                                                                
    SQL> select object_name, object_type from user_objects where object_name = 'MV_TABLE' ;
    OBJECT_NAME                                                                                                                      OBJECT_TYPE                              
    MV_TABLE                                                                                                                         TABLE                                    
    MV_TABLE                                                                                                                         MATERIALIZED VIEW                        
    SQL> insert into mv_table values (999, 100) ;
    insert into mv_table values (999, 100)
    ERROR at line 1:
    ORA-01732: data manipulation operation not legal on this view
    SQL> update mv_table set totalsal = totalsal * 1.1 where department_id = 10 ;
    update mv_table set totalsal = totalsal * 1.1 where department_id = 10
    ERROR at line 1:
    ORA-01732: data manipulation operation not legal on this view
    SQL> delete from mv_table where totalsal <= 10000 ;
    delete from mv_table where totalsal <= 10000
    ERROR at line 1:
    ORA-01732: data manipulation operation not legal on this view While investigating for this thread I actually made my own question redundant as the answer became gradually clear:
    When using complex ETL's, I just need to make sure the complexity is located in the ETL loading the detailed table, not the aggregate
    I'll try to clarify through an example:
    - A detailed Table DET_SALES exists with Sales per Day, Store & Product
    - An aggregated table AGG_SALES_MM exists with Sales, SalesStore per Month, Store & Product
    - An ETL exists to load AGG_SALES_MM where Sales = SUM(Sales) & SalesStore = (SUM(Sales) Across Store)
    --> i.e. the SalesStore measure will be derived out of a lookup
    - A (Prebuilt) Materialized View will exist with the same column definitions as the ETL
    --> to allow query-rewrite to know when to access the table
    My concern was how to include the SalesStore in the materialized view definition (--> complex SQL!)
    --> I should actually include SalesStore in the DET_SALES table, thus:
    - including the 'Across Store' function in the detailed ETL
    - rendering my Aggregation ETL into a simple GROUP BY
    - rendering my materialized view definition into a simple GROUP BY as wellNot sure how close your example is to your actual problem. Also don't know if you are doing an incremental/complete data load and the data volume.
    But the "SalesStore = (SUM(Sales) Across Store)" can be derived from the aggregated MV using analytical function. One can just create a normal view on top of MV for querying. It is hard to believe that aggregating in detail table during ETL load is the best approach but what do I know?

  • Number precision in Clustering rules

    When runing O-Cluster I get rules with many variables (say VarX) showing the following number:
    if ..... VarX>=1.40129546324817E-45 then Cluster equal .....
    I set the preferences with precision =4
    Shouldn´t I get then VRAX>=0 ?
    Tkx
    D

    Todd gives a better suggestion.
    I could be wrong, but I believe views in general pull their datatypes from their base sources. Therefore if you want your materialized view datatypes to be NUMBER(5,0) you will have to alter your base tables as such.
    Otherwise, if you don't care about the datatype just the value, then in the select part of your materialized view you could use substr and possibly instr to get the length of five you desire and convert back to a number.
    Message was edited by:
    splazm

  • How to get Materialized View to ignore unused columns in source table

    When updating a column in a source table, records are generated in the corresponding materialized view log table. This happens even if the column being updated is not used in any MV that references the source table. That could be OK, so long as those updates are ignored. However they are not ignored, so when the MV is fast refreshed, I find it can take over a minute, even though no changes are required or made. Is there some way of configuring the materialized view log such that the materialized view refresh ignores these updates ?
    So for examle if I have table TEST:
    CREATE table test (
    d_id NUMBER(10) PRIMARY KEY,
    d_name VARCHAR2(100),
    d_desc VARCHAR2(256)
    This has an MV log MLOG$_TEST:
    CREATE MATERIALIZED VIEW LOG ON TEST with rowid, sequence, primary key;
    CREATE MATERIALIZED VIEW test_mv
    refresh fast on demand
    as
    select d_id, d_name
    from test;
    INSERT 200,000 records
    exec dbms_mview.refresh('TEST_MV','f');
    update test set d_desc = upper(d_desc) ;
    exec dbms_mview.refresh('TEST_MV','f'); -- This takes 37 seconds, yet no changes are required.
    Oracle 10g/11g

    I would love to hear a positive answer to this question - I have the exact same issue :-)
    In the "old" days (version 8 I think it was) populating the materialized view logs was done by Oracle auto-creating triggers on the base table. A "trick" could then make that trigger become "FOR UPDATE OF <used_column_list>". Now-a-days it has been internalized so such "triggers" are not visible and modifiable by us mere mortals.
    I have not found a way to explicitly tell Oracle "only populate MV log for updates of these columns." I think the underlying reason is that the MV log potentially could be used for several different materialized views at possibly several different target databases. So to be safe that the MV log can be used for any MV created in the future - Oracle always populates MV log at any update (I think.)
    One way around the problem is to migrate to STREAMS replication rather than materialized views - but it seems to me like swatting a fly with a bowling ball...
    One thing to be aware of: Once the MV log has been "bloated" with a lot of unneccessary logging, you may perhaps see that all your FAST REFRESHes afterwards becomes slow - even after the one that checked all the 200000 unneccessary updates. We have seen that it can happen that Oracle decides on full table scanning the MV log when it does a fast refresh - which usually makes sense. But after a "bloat" has happened, the high water mark of the MV log is now unnaturally high, which can make the full table scan slow by scanning a lot of empty blocks.
    We have a nightly job that checks each MV log if it is empty. If it is empty, it locks the MV log and locks the base table, checks for emptiness again, and truncates the MV log if it is still empty, before finally unlocking the tables. That way if an update during the day has happened to bloat the MV log, all the empty space in the MV log will be reclaimed at night.
    But I hope someone can answer both you and me with a better solution ;-)

  • Use of db sequence in a materialized view

    Hi,
    Will it be possible to use a database sequence in a materialized view?
    The materialized view is to return the result set of query that joins multiple tables. One of the columns in the result set - the to-be-created materialized view - is null and requires a sequence.
    Will it be possible to include a db sequence in the query?
    Example:
    create materialized view example_mview
    as
    select example_sequence.nextval, table1.'*', table2.'*'
    from example_table1 table1, example_table2 table2
    where table1.id=table2.id

    What is the purpose of such numbering? To number each row?
    If so - then use ROWNUM as 1st column.
    SQL>with ddd
           as
           (select 333 COL from dual union all select 5444 COL from dual)
           select rownum,COL from ddd;ROWNUM COL
    1 333
    2 5444

  • Regd FAST refresh option in a Materialized view

    Hi All,
    I am using a pipeline function in which I am creating a table of records and a few cursors to fetch data from various tables.
    Now this PL/SQL table is being used to construct a Materialized view.
    Creation of Materialized view is happening fine but not with FAST refresh option. It gives an error " Cannot create a FAST refresh Materialized view from a complex query."
    The query which I have used for the view creation is
    CREATE MATERIALIZED VIEW CUSTOM.ABC
    PCTFREE 0
    BUILD IMMEDIATE
    REFRESH FAST ON DEMAND
    AS
    SELECT A.Number,
    A.Guarantors_Number,
    A.Guarantors_Name,
    A.Personal_Garantee_PCNT,
    A.Company, LG.Source_System,
    A.Type_of_Info,
    A.File_Gen_Date,
    A.Periodicity
    FROM
    TABLE(CUSTOM.CDM_LG_PACK_PF.CDM_LG_FUNC) A;
    where CDM_LG_PACK_PF is the package and CDM_LG_FUNC is the pipeline function I have written to fetch all the records.
    Please help me on how can I do a FAST refresh on this materialized view.
    Thanks in advance,
    Gaurav

    Welcome to the forum!
    FAST refresh doesn't mean that the operation is fast (time wise), it means it's an incremental refresh.
    If you have a complex query, you can't use a FAST refresh - that's what the exception tells you.

  • How do I figure where is the data in a materialized view coming from

    Hi: when I run select NAME, OWNER from dba_mview_refresh_times, I see a number of materialized views. How do I find more details about this view i.e where is the data coming from and which fields. The source table that is in another database changed. But the view on my database where the materialized view exist has not changed. I want to confirm from where is data coming in this view
    TIA
    Ravi

    SQL>  select * from dict where table_name like 'ALL%MVIEW%'
    TABLE_NAME                     COMMENTS                                                             
    ALL_BASE_TABLE_MVIEWS          All materialized views with log(s) in the database that the user can s
                                   ee                                                                   
    ALL_MVIEWS                     All materialized views in the database                               
    ALL_MVIEW_AGGREGATES           Description of the materialized view aggregates accessible to the user
    ALL_MVIEW_ANALYSIS             Description of the materialized views accessible to the user         
    ALL_MVIEW_COMMENTS             Comments on materialized views accessible to the user                
    ALL_MVIEW_DETAIL_PARTITION     Freshness information of all PCT materialized views in the database  
    ALL_MVIEW_DETAIL_RELATIONS     Description of the materialized view detail tables accessible to the u
                                   ser                                                                  
    ALL_MVIEW_DETAIL_SUBPARTITION  Freshness information of all PCT materialized views in the database  
    ALL_MVIEW_JOINS                Description of a join between two columns in the                     
                                   WHERE clause of a materialized view accessible to the user           
    ALL_MVIEW_KEYS                 Description of the columns that appear in the GROUP BY               
                                   list of a materialized view accessible to the user                   
    ALL_MVIEW_LOGS                 All materialized view logs in the database that the user can see     
    ALL_MVIEW_REFRESH_TIMES        Materialized views and their last refresh times  for each master table
                                    that the user can look at                                           
    ALL_REGISTERED_MVIEWS          Remote materialized views of local tables that the user can see      
    13 rows selected.

  • Transform 3D to 2D Data via a Materialized View

    Hi,
    I'm playing with Geoserver against an Oracle Locator database. Things are starting well, but I did notice a bug where 3D points and lines are not supported. I guess this is an issue with GeoTools. Anybody have a way to transform my 3D data to 2D. Since I do use the 3rd dimension for storing elevation, I don't want to lose the data. So I was thinking that I could create materialized views to "virtually strip" the 3rd dimension. Any thoughts? I'm not very strong in PL/SQL, so any code hints would be greatly appreciated as well.
    Thanks!
    Jeff

    I would say the compiled pl/sql would be faster (it would also depend on whether you compiled to the pl/sql virtual machine code - MP-code or the machine-dependent code of the host's C compiler if you chose native copilation): I am coding a Java version of my GEOM.SDO_CENTROID function so will be in a better position to say, categorically, one way or the other.
    In my free pl/sql packages there are these functions in case anyone is interested:
       --  @function To_2D
       --  @precis   Converts a 3D geometry to a 2D geometry
       --  @version  2.0
       --  @usage    v_2D_geom := geom.To_2D(MDSYS.SDO_Geometry(3001,....)
       --  @history  Albert Godfrind, July 2006, Original Coding
       --  @history  Bryan Hall,      July 2006, Modified to handle points
       --  @history  Simon Greener,   July 2006, Integrated into geom with GF.
       Function To_2D( p_3D_geom IN MDSYS.SDO_Geometry )
         Return MDSYS.SDO_Geometry deterministic;
       --  @function To_3D
       --  @precis   Converts a 2D geometry to a 3D geometry
       --  @version  1.0
       --  @usage    v_3D_geom := geom.To_3D(MDSYS.SDO_Geometry(2001,....),50)
       --  @history  Simon Greener,   May 2007 Original coding
       Function To_3D( p_2D_geom   IN MDSYS.SDO_Geometry,
                       p_default_z IN NUMBER := NULL)
         Return MDSYS.SDO_Geometry deterministic;
       /** @Function : FIX_3D_Z
       **  @Precis   : Checks the Z ordinate in the SDO_GEOMETRY and if NULL changes to p_default_z value
       **  @Note     : Needed as MapServer appears to not handle 3003/3007 polygons with NULL Z values in the sdo_ordinate_array
       **  @History  : Simon Greener  -  JUNE 4th 2007  - Original Coding
       Function Fix_3D_Z( p_3D_geom   IN MDSYS.SDO_Geometry,
                          p_default_z IN NUMBER := -9999 )
                Return MDSYS.SDO_Geometry Deterministic;
      /** Function just to change a single point coded in sdo_ordinates to sdo_point representation
      * @param p_geometry  A sdo_geometry object.
      Function ToSdoPoint ( p_geometry in MDSYS.SDO_Geometry )
        return MDSYS.SDO_Geometry Deterministic;Simon

  • Way to add an additional column that acts as a PK in a Materialized View?

    I want to create a materialized view that also has an index column. A unique number sequence assigned to each record. Is this even possible? Can a materialized view do this, and would the indexes stay the same on a refresh?
    Any help would be greatly appreciated.

    Materialized views are copies of data or aggregations. They can be used to replicate all or part of a table, or to replicate the result of a query against multiple tables. The big advantage they have is that unlike a standard view, which can return the same data, you can index the materialized view to improve performance. These indexes will be maintained and updated during the refresh process.
    Refer to Metalink document: 76673.1 or the Oracle Concepts manual for more information.

  • Problem encountered when join two remote tables in a materialized view

    I'm using oracle 9.2.0.6
    1> I have two tables:
    CREATE TABLE TEST
    A VARCHAR2(100 BYTE),
    C DATE
    CREATE TABLE TEST1
    A VARCHAR2(100 BYTE),
    B TIMESTAMP
    2>. I defined a prebuild table:
    CREATE TABLE MV_TEST1
    ID1 ROWID,
    A VARCHAR2(100 BYTE),
    ID2 ROWID,
    B TIMESTAMP(6),
    C DATE
    3> I created mview logs:
    CREATE MATERIALIZED VIEW LOG ON PSI_TEST.TEST
    WITH ROWID
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW LOG ON PSI_TEST.TEST1
    WITH ROWID
    INCLUDING NEW VALUES;
    4> when I create mview:
    CREATE MATERIALIZED VIEW PSI_TEST.MV_TEST1
    ON PREBUILT TABLE WITH REDUCED PRECISION
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    AS
    select
    test.rowid id1,
    test.a,
    test1.rowid id2,
    test1.b,
    cast(null as date) c
    from test , test1
    where test.a = test1.a(+);
    It is created successfully.
    5> problem:
    when I use remote tables to do the same thing, say test and test1 are in another instance and are connected by a dbLink, I couldn't create the mview successfully:
    CREATE MATERIALIZED VIEW PSI_TEST.MV_TEST1
    ON PREBUILT TABLE WITH REDUCED PRECISION
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    AS
    select
    a.rowid id1,
    a.a,
    b.rowid id2,
    b.b,
    cast(null as date) c
    from test@dbl a, test1@dbl b
    where a.a = b.a(+);
    when run above statement, I got:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    Any ideas? Or joining two table through a dblink for a mview is not allowed at all?
    Thanks in advance.

    No one has a clue?
    Message was edited by:
    lzhwxy

Maybe you are looking for