Materialized view query (Oracle 9i)

I have dropped a materialized view query and trying to create the same with additional columns in the prebuilt table.
Option - 1
when Iam using a query in the materialized view query "select * from schema.table@link, with refresh mode fast option, the database throws an error " no table or view exists"
Option - 2
When Iam using a query in the materialized view query "select * from schema.table@link, with refresh mode option either complete or force, it gets created.
I need to create the above materialized view query in the fast mode option, Please help.
-bala

Hi,
Does a table named profit_mvw already exist?
The following example illustrates the two steps required to register a user-defined table. First, the table is created, then the materialized view is defined using exactly the same name as the table. This materialized view sum_sales_tab is eligible for use in query rewrite.
CREATE TABLE sum_sales_tab
PCTFREE 0 TABLESPACE demo
STORAGE (INITIAL 16k NEXT 16k PCTINCREASE 0) AS
SELECT s.prod_id, SUM(amount_sold) AS dollar_sales,
SUM(quantity_sold) AS unit_sales
FROM sales s GROUP BY s.prod_id;
CREATE MATERIALIZED VIEW sum_sales_tab
ON PREBUILT TABLE WITHOUT REDUCED PRECISION
ENABLE QUERY REWRITE AS
SELECT s.prod_id, SUM(amount_sold) AS dollar_sales,
SUM(quantity_sold) AS unit_sales
FROM sales s GROUP BY s.prod_id;
Regards,
Simon

Similar Messages

  • Spatial vs. materialized views/query rewrite

    Dear all,
    we are trying to use Spatial (Locator) functionality together with performance optimization using materialized views and query rewrite, and it does not seem to work. Does anybody has experience with this?
    The problem in more detail:
    * There is a spatial attribut (vom Typ GEOMETRY) in our table;
    * we define a materialized view on that table;
    * we run a query that could be better answered using the materialized view with query rewrite;
    *the optimizer does not choose the plan using the materialized view, query rewrite does not take place;
    This happenes, even if neither the materialized view, nor the query contains the spatial attribut.
    The explanation given by the procedure DBMS_MVIEW.Explain_Rewrite is:
    "QSM-01064 query has a fixed table or view Cause: Query
    rewrite is not allowed if query references any fixed tables or views"
    We are using Oracle 9R2, Enterprise Edition, with locator. Nevertheless, it would also be interesting, if there is any improvement in 10g?
    A more complicated task, using materialized views to optimize spatial operations (e.g., sdo_relate) would also be very interesting, as spatial joins are very expensive operations.
    Thanks in advance for any comments, ideas!
    Cheers,
    Gergely Lukacs

    Hi Dan,
    thanks for your rapid response!
    A simple example is:
    alter session set query_rewrite_integrity=trusted;
    alter session set query_rewrite_enabled=true;
    set serveroutput on;
    /* Creating testtable */
    CREATE TABLE TESTTABLE (
    KEY1 NUMBER (4) NOT NULL,
    KEY2 NUMBER (8) NOT NULL,
    KEY3 NUMBER (14) NOT NULL,
    NAME VARCHAR2 (255),
    X NUMBER (9,2),
    Y NUMBER (9,2),
    ATTR1 VARCHAR2 (2),
    ATTR2 VARCHAR2 (30),
    ATTR3 VARCHAR2 (80),
    ATTR4 NUMBER (7),
    ATTR5 NUMBER (4),
    ATTR6 NUMBER (5),
    ATTR7 VARCHAR2 (40),
    ATTR8 VARCHAR2 (40),
    CONSTRAINT TESTTABLE_PK
    PRIMARY KEY ( KEY1, KEY2, KEY3 ));
    /* Creating materialized view */
    CREATE MATERIALIZED VIEW TESTTABLE_MV
    REFRESH COMPLETE
    ENABLE QUERY REWRITE
    AS SELECT DISTINCT ATTR7, ATTR8
    FROM TESTTABLE;
    /* Creating statistics, just to make sure */
    execute dbms_stats.gather_table_stats(ownname=> 'TESTSCHEMA', tabname=> 'TESTTABLE', cascade=>TRUE);
    execute dbms_stats.gather_table_stats(ownname=> 'TESTSCHEMA', tabname=> 'TESTTABLE_MV', cascade=>TRUE);
    /* Explain rewrite procedure */
    DECLARE
    Rewrite_Array SYS.RewriteArrayType := SYS.RewriteArrayType();
    querytxt VARCHAR2(1500) :=
    'SELECT COUNT(*) FROM (
    SELECT DISTINCT
    ATTR8 FROM
    TESTTABLE
    i NUMBER;
    BEGIN
    DBMS_MVIEW.Explain_Rewrite(querytxt, 'TESTTABLE_MV', Rewrite_Array);
    FOR i IN 1..Rewrite_Array.count
    LOOP
    DBMS_OUTPUT.PUT_LINE(Rewrite_Array(i).message);
    END LOOP;
    END;
    The message you get is:
    QSM-01009 materialized view, string, matched query text
    Cause: The query was rewritten using a materialized view, because query text matched the materialized view text.
    Action: No action required.
    i.e. query rewrite works!
    /* Adding geometry column to the testtable -- not to the materialized view, and not to the query! */
    ALTER TABLE TESTTABLE
    ADD GEOMETRYATTR mdsys.sdo_geometry;
    /* Explain rewrite procedure */
    DECLARE
    Rewrite_Array SYS.RewriteArrayType := SYS.RewriteArrayType();
    querytxt VARCHAR2(1500) :=
    'SELECT COUNT(*) FROM (
    SELECT DISTINCT
    ATTR8 FROM
    TESTTABLE
    i NUMBER;
    BEGIN
    DBMS_MVIEW.Explain_Rewrite(querytxt, 'TESTTABLE_MV', Rewrite_Array);
    FOR i IN 1..Rewrite_Array.count
    LOOP
    DBMS_OUTPUT.PUT_LINE(Rewrite_Array(i).message);
    END LOOP;
    END;
    The messages you get are:
    QSM-01064 query has a fixed table or view
    Cause: Query rewrite is not allowed if query references any fixed tables or views.
    Action: No action required.
    QSM-01019 no suitable materialized view found to rewrite this query
    Cause: There doesn't exist any materialized view that can be used to rewrite this query.
    Action: Consider creating a new materialized view.
    i.e. query rewrite does not work!
    If this works, the next issue is to use materialized views for optimizing spatial operations, e.g., a spatial join. I can supply you with an example, if necessary (only makes sense, I think, after the first problem is solved).
    Thanks in advance for any ideas, comments!
    Cheers,
    Gergely

  • Creating a Materialized View in Oracle 8i

    Hello -
    What are the steps and privileges required to create a materialized view in Oracle 8i?
    Thanks

    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.
    Thanks
    Manish

  • Materialized view in Oracle 9i/10g SE?

    Hi All,
    Can we define MV's in standard edition of oracle9i & 10g database? If yes, are there any limitations on creation of MV's in Standard edition compare to Enterprise edition like Query rewrite, creation of log tables etc?
    As per link : http://www.dba-oracle.com/art_so_oracle_standard_enterprise_edition.htm , MV's seems to be avialable in EE.
    Also let me know if there is any document available to general public for comparision of various edition features of oracle database version.
    Thanks in advance,
    AJ

    As far as I'm aware, you can create MV in standard and also there is no limitation that I'm aware off
    Standard and Enterprise Edition
    A. Basic replication (MV replication)
    \- transaction based
    - row-level
    - asynchronous from master table to MV (Materialized View)
    - DML replication only
    - database 7 / 8.0 / 8i / 9i / 10g
    Variants:
    1. Read-only MV replication
    2. Updateable MV replication:
    2.1 asynchronous from MV to master
    2.2 synchronous from MV to master
    3. Writeable MV replication
    Enterprise Edition only
    B. Multimaster replication
    \- transaction based
    - row-level or procedural
    - asynchronous or synchronous
    - DML and DDL replication
    - database 7 / 8.0 / 8i / 9i / 10g
    - Enterprise Edition only
    Variants:
    1. row-level asynchronous replication
    2. row-level synchronous replication
    3. procedural asynchronous replication
    4. procedural synchronous replication
    C. Streams replication
    (Standard Edition 10g can execute Apply process)
    \- (redo) log based
    - row-level
    - asynchronous
    - DML and DDL replication
    - database 9i / 10g (10g has Down Streams Capture)

  • Materialized views - query rewrite -- optional joins & dimensions

    Hi,
    I've implemented a number of materialized views that are accessible via query rewrite.
    Most of these views make use of duplicate tables (DD_TIME table is joined via purchase, load, process, ... date columns)
    I've also created a dimension to make Oracle aware of the time relation (month is child of year...)
    The issue:
    --> If I create the mat. view with inner joins, query rewrite works with the dimensions, but I need to provide ALL joined tables in the query
    --> If I create the mat. view with outer joins, query rewrite works even with 1 joined table, but the dimension seems to be ignored
    How can I create 'optional' joins in the Mat. View while making use of dimensions for rollup?
    (the limitations on materialized view delta joins mentioned on [oracle docs|http://docs.oracle.com/cd/B28359_01/server.111/b28313/qradv.htm#autoId16] kinda has me worried)
    Example Mat. View:
    CREATE MATERIALIZED VIEW DA_REPOSITORY_MERCHANT_MM
    ... ENABLE QUERY REWRITE
    AS SELECT
    DDFPC.YEAR_NO,
    DDFPC.YEAR_MONTH,
    DDPUR.YEAR_NO,
    DDPUR.YEAR_MONTH,
    SUM( DF.TRANSACTION_AMOUNT )
    FROM DF_REP DF,
    DD_TIME DDFPC,
    DD_TIME DDPUR
    WHERE DF.FPC_DTE = DDFPC.DAY_DATE(+)
    AND DF.PUR_DTE = DDPUR.DAY_DATE(+)
    GROUP BY
    DDFPC.YEAR_NO,
    DDFPC.YEAR_MONTH,
    DDPUR.YEAR_NO,
    DDPUR.YEAR_MONTH
    Example query launched:
    SELECT
    DDFPC.YEAR_NO,
    SUM( DF.TRANSACTION_AMOUNT )
    FROM DF_REP DF,
    DD_TIME DDFPC
    WHERE DF.FPC_DTE = DDFPC.DAY_DATE
    GROUP BY
    DDFPC.YEAR_NO

    The problem was resolved by setting foreign keys in the fact table and making them not nullable + using inner joins.
    --> this informs oracle there can be no difference between a query without the dimensions and a query with the dimensions.
    As a result, the materialized view can contain 1 fact linked to 2 dimension tables, but the query rewrite will work for queries on the 1 fact joined with only 1 dimension

  • Database replication with updatable materialized view in oracle 10gR2

    I neet to set up 1 central server and two local databases ....the local database will hold materialized view....now how to replicate data...in this scenario...please help as soon as possible...i am in rush.....
    the database i use is oracle 10g Release 2
    Edited by: user9932019 on Sep 4, 2009 2:25 AM

    It's not a process that can be explained in a forums posting. You have to understand the steps.
    Here are some other examples :
    http://www.orafaq.com/wiki/Scripts#Oracle_Advanced_Replication_Scripts

  • What's the impact of rowid materialized view in oracle 10g

    Hello to all ;
    Oracle official  docs  saying
    ROWID materialized views should be used only for materialized views based on master tables from an Oracle7 database, and should not be used from Oracle8 or higher.
    For 10g or higher versions can we consider rowid materizlized view ?
    product 10.2.0.4 and 11g r2 on Redhat 5.1

    No
    should not be used from Oracle8 or higher10g is higher

  • How to change Materialized View query?

    Hi all,
    sorry for this newbie question, but I'm not able to work out this matter...
    How can I change the query used by a materialized view without dropping an recreate all, and using another user(SYS in my case)?
    It looks like the command 'alter materialized view ...' does not allow this, am I wrong?
    thanks a lot
    aldo

    You quick answer saved me a lot of other unsuccessfully searches.
    thanks
    aldo

  • Problem: Materialized View between Oracle servers w/different CHARACTERSET

    I am trying to create a MATERIALIZED VIEW where the master table is a remote Oracle 8 server with NLS_CHARACTERSET = 'WE8ISO8859P1'. The destination view is an Oracle 10g with NLS_CHARACTERSET = 'AL32UTF8'.
    I am getting error: ORA-12703: this character set conversion is not supported.
    I've tried to use CONVERT on my SELECT statment but according to the error message, CONVERT does not support 'AL32UTF8'.
    I need help. Please!

    First off, I'd strongly suggest reading through Metalink Note 237593.1 Problems connecting to AL32UTF8 databases from older versions (8i and lower).
    There is a good chance that the destination database character set will need to be converted to UTF8 rather than AL32UTF8 (assuming that this isn't going to cause issues with surrogate pairs). You may be able to keep the destination character set unchanged if you install at least the 8.1.7.4 patchset on the source database as well as a hanfddful of different one-off patches, but it looks like you're probably going to need to change the destination character set.
    Justin

  • Exporting data from a materialized view in Oracle 10g

    Can anybody tell me how to export data to a remote server and import data in that remote server without using ftp utility. Actually I want to export the data from a materialized view to the remote server and import the same in the remote server.
    If everything works well, I'll put the exporting and importing in a cronjob.
    Please let me know how can I do that if that's possible .
    Any reply would be appreciated.
    Thanks.

    Here is what I'm trying to do.
    I created materialized views using multiple base tables in my local server and the base tables got populated using a long process.
    Now I want to copy those data alone to some remote server since it doesn't have any base tables in it. For now, the remote server should depends on the localserver's data. I'm going to use the remote server's data for some testing purposes.
    I know it is easy to create mat.views in the remote server but it doesn't have I don't want to do that now. I just want to copy the snapshots from my local server to the remote server.
    Please let me know how to do that.
    Thanks.

  • Materialized VIews Query

    Hi,
    I want to Insert a record in my table every time materilized view brings in a new record . Is this possible , if yes anyone please suggest solution.
    Thanks
    Aali

    Hi,
    check this link for TRIGGER on MV,
    Materialized View Trigger does not fire
    Also did you try creating a trigger on the TABLE which will INSERT into the TABLE where you want it to be inserted.
    Thanks

  • Materialized Views query is ZERO count

    When doing refreshes the Mviews come up as ZERO count...
    any option we can do to prevent this?
    DB is 10.2.0.5
    thanks

    You possibly have another job (scheduled through DBA_JOBS or DBA_SCHEDULER_JOBS or cron or an external scheduler OR initiated by a user or application) that does the refresh (truncate and refresh) between the time you complete a refresh and you query 2 hours later ?
    Possibly the source has no data at the next refresh so the next refresh causes the MV to be Zero count.
    Then, at the third execution, the source has data so the MV now again appears with data ?!
    Hemant K Chitale

  • Is materialized view available in Oracle SE ?

    Hi all,
    I have questions on materizlalized view :
    1) Is materialized view available in Oracle Standard Edition ?
    2) what is the meaning of "Materialized View Query Rewrite " ?
    Thank you very much,
    xtanto

    Hi all,
    I have questions on materizlalized view :
    1) Is materialized view available in Oracle Standard
    Edition ?http://www.oracle.com/technology/products/database/oracle11g/pdf/database-11g-product-family-technical-whitepaper.pdf
    >
    2) what is the meaning of "Materialized View Query
    Rewrite " ?http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/qrbasic.htm#CIHDIEDI

  • Invalid Materialized view Oracle 8

    Hi,
    I have a problem with a Invalid materialized view in Oracle 8.
    this view is in a .sql file. When the SQL file runs and the view is invalid the the loading is stopped.
    Does anyone know if it's possible in Oracle 10 that Oracle solves the problem (with the view) it self, or that I have to repair it myself and run the file again?
    thanks for the help
    kinds regards,
    Richard van der Haag

    Richard,
    There is nothing that on MV gets done automatically in 10g. Please post your query and we will see where the error is.
    Thanks
    G

  • Fast Refresh Nested Materialized View problem in ORACLE 9i 9.2.0.7

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

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

Maybe you are looking for

  • Bridge CS6 can't open image with Photoshop CS6

    I installed Bridge CS6 and Photoshop CS6 with my Mac Pro with drive 1, which was cloned with drive 2 as a backup. Now every time I try to open my RAW file in Bridge, it opens the file with the Photoshop with drive 2 instead of 1. I have tried to ejec

  • Dreamweaver CS3 Paste HTML Problem

    Hi, I'm a fairly basic user of Dreamweaver CS3. I used to be able to paste HTML into webpages with no problem. I have recently upgraded to CS3 and that menu command (Paste HTML) seems to have gone. Can anybody help? Thanks, your help would be appreci

  • How to use a class in Flash

    I'm trying to use a class (LoadSwf.as) in Flash. The code is listed at the bottom. Here's my code in Flash: import LoadSwf var myLoader:LoadSwf=new LoadSwf() addChild(myLoader) The file being imported (Login1.swf) contains a very simple ComboBox. Whe

  • Inactive employess payments to be made

    Dear All, I need a help, my Client Side , there is a requirement from my client know that when , the 01 VRS is given then that employees becomes in active from systems point of view, 02 Full and final settlement. if any payment is suppose to be made

  • BPC 7.5 - Member properties disabled (grey marked)

    Since the upgrade to BPC 7.5 some of the member properties are greyed (disabled). Is it possible to change this setting somewhere?