Can a SQL WITH Clause be used in Materialized View

Hello,
Can we use SQL WITH clause in Materialized View.
Thanks

Hello,
Here is an example
CREATE MATERIALIZED VIEW MV_TEST
BUILD IMMEDIATE
REFRESH FORCE ON DEMAND
AS
WITH t AS (SELECT owner, object_type, COUNT ( * )
           FROM my_objects
           GROUP BY object_type, owner)
SELECT *
FROM t
WHERE owner IN ('SYS', 'SYSTEM');Regards

Similar Messages

  • Oracle SQL “WITH clause” support

    It doesn't appear that JDeveloper 10.1.2 ADF BCs support using the WITH clause in an expert mode View. It says it's valid when tested, but the wizard loses all attribute references. Looking in the <view_object>.xml file, all attribute metdata has been removed from the file.
    I can work around it easily by just repeating the sub-query. I was just wondering if it was not supported yet by the wizard, or is it a bug that I should file?
    Thanks
    Erik

    Since it isn't extremely important in this case, I'll just assume that ADF doesn't currently support SQL99 features in case anyone else ever asksthe same question.
    Thanks
    Erik

  • Can I mail with  attachment by using NSURL maito?

    Can I mail with attachment by using NSURL maito?

    RainApple wrote:
    It seems there are open source project to implement it.
    Custom API...
    Google for skpsmtpmessage

  • Is there any apps or something else can all compatible with PPT, I use Keynote.If there is,pls tell me thanks.

    Is there any apps or something else can all compatible with PPT, I use Keynote.If there is,pls tell me thanks.

    Open Office
    Libre Office
    Neo Office
    MS Office
    Keynote

  • Very high parse times for query rewrite using cube materialized views

    We recently upgraded to version 11.2.0.2 (both AWM and Oracle database server). We are using cube materialized views with query rewrite enabled. Some observations of changes that took place when we rebuilt all the dimensions and cubes in this version:
    1. Queries against the base tables take about 35 seconds to parse. Then they execute in a tenth of a second. Even simple queries that just get a sum of the amount from the fact table (which is joined to all the dimensions) takes that long to parse. Once parsed, the queries fly.
    2. I noticed that the materialized views used to use grouping sets in the group by clause in version 11.2.0.1, but now they use group by rollup, rollup, rollup...
    If we disable query rewrite on the MV or for my session, parse times drop to less than a second. Ideas?

    There does appear to be a slow down in parse times between 11.1.0.7 and 11.2. We are still investigating this, but in the meantime here is a way to force the code in 11.2 to generate a GROUPING SETS clause instead of the new ROLLUP syntax.
    The trick is to create a dummy hierarchy containing only the leaf level. This is necessary for all dimensions that currently have a single hierarchy. As a simple example I created a dimension, PROD, with three levels, A, B, and C, in a single hierarchy. I then created a one dimensional cube, PC. Here is the SELECT statement for the MV in 11.2. Note the ROLLUP clause in the GROUP BY.
    SELECT
      GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")  SYS_GID,
      (CASE GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")
       WHEN 3
       THEN TO_CHAR(('A_' || T3."CLASS_ID") )
       WHEN 1
       THEN TO_CHAR(('B_' || T3."FAMILY_ID") )
       ELSE TO_CHAR(('C_' || T3."ITEM_ID") )  END)     "PROD",
      T3."CLASS_ID" "D1_PROD_A_ID",
      T3."FAMILY_ID" "D1_PROD_B_ID",
      T3."ITEM_ID" "D1_PROD_C_ID",
      SUM(T2."UNIT_PRICE")     "PRICE",
      COUNT(T2."UNIT_PRICE")  "COUNT_PRICE",
      COUNT(*)  "SYS_COUNT"
    FROM
      GLOBAL."PRICE_AND_COST_FACT" T2,
      GLOBAL."PRODUCT_DIM" T3
    WHERE
      (T3."ITEM_ID" = T2."ITEM_ID")
    GROUP BY
      (T3."CLASS_ID") ,
      ROLLUP ((T3."FAMILY_ID") , (T3."ITEM_ID") )Next I modified the dimension to add a new hierarchy, DUMMY, containing just the leaf level, C. Once I have mapped the new level and re-enabled MVs, I get the following formulation.
    SELECT
      GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")  SYS_GID,
      (CASE GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")
       WHEN 3
       THEN ('A_' || T3."CLASS_ID")
       WHEN 1
       THEN ('B_' || T3."FAMILY_ID")
       WHEN 0
       THEN ('C_' || T3."ITEM_ID")
       ELSE NULL END)  "PROD",
      T3."CLASS_ID" "D1_PROD_A_ID",
      T3."FAMILY_ID" "D1_PROD_B_ID",
      T3."ITEM_ID" "D1_PROD_C_ID",
      SUM(T2."UNIT_PRICE")     "PRICE",
      COUNT(T2."UNIT_PRICE")  "COUNT_PRICE",
      COUNT(*)  "SYS_COUNT"
    FROM
      GLOBAL."PRICE_AND_COST_FACT" T2,
      GLOBAL."PRODUCT_DIM" T3
    WHERE
      (T3."ITEM_ID" = T2."ITEM_ID")
    GROUP BY
      GROUPING SETS ((T3."CLASS_ID") , (T3."FAMILY_ID", T3."CLASS_ID") , (T3."ITEM_ID", T3."FAMILY_ID", T3."CLASS_ID") )This puts things back the way they were in 11.1.0.7 when the GROUPING SETS clause was used in all cases. Note that the two queries are logically equivalent.

  • Modify query used in Materialized View

    Are there any ways to modify the query used in materialized view without dropping the materialized view. I dont think alter materialized view has such an option.
    Please provider me your suggestions.

    you have to give "ENABLE QUERY REWRITE" option then u can change your query

  • Use of materialized views?

    can any one tell me the use of materilized views in oracle?
    explain briefly please...........

    ratnakar wrote:
    can any one tell me the use of materilized views in oracle?
    explain briefly please...........In Views, what happens is there is not data storage in it. Every time you execute the View, it has to pull the data using its query from the Base tables.
    Materialized Views are replica (or Snapshot ) of data from some master site to another site.
    It has the capability to store data. When you execute the MView it pulls data stored in it.
    There is something called as MView Refresh which pulls data from the base tables and stores in this MView's storage unit. And when you read the MView data is pulled from this storage unit (and doesn't hit the base tables).
    This somewhat ensures data availability always.
    Please read this thoroughly... http://docs.oracle.com/cd/B28359_01/server.111/b28326/repmview.htm

  • PL/SQL WITH Clause

    Hi Gurus,
    I have been trying to find more information regarding the WITH CLAUSE, but most of the info I find is related to Forums. Do you know where i could find Oracle specific documentation on this? I really like using that clause, but i have noticed some drastic performance differences with it compared to the same query run outside of the WITH CLAUSE.
    Just wanted to find some documentation on it and can't seem to find anything.
    As always greatly appreciate the info/feedback.
      Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
      PL/SQL Release 10.2.0.3.0 - Production
      CORE     10.2.0.3.0     Production
      TNS for Linux: Version 10.2.0.3.0 - Production
      NLSRTL Version 10.2.0.3.0 - ProductionThanks,
    S

    Here it goes:
    Using With Clause:
    11g
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10578/tdpdw_sql.htm#TDPDW0073
    10g
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1670
    subquery_factoring_clause:
    11g
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_10002.htm#SQLRF01702
    10g
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#SQLRF01702
    Edited by: fsitja on Apr 15, 2010 5:14 PM

  • With clause join using ISO JOIN Sysntax

    Hi,
    One of my query looks like:
    SELECT t2.col1,
                  t3.col1,
                  t3.col2
    FROM t2
    JOIN t2 ON t2.col1 = t3.col1;
    Now I need to use a WITH clause to hold some values which has to be used to filter the results from the original query. Something like:
    with t1 AS (Select col1
                       FROM tab1)
    SELECT t2.col1,
                  t3.col1,
                  t3.col2
    FROM t2
    JOIN t3 ON t2.col1 = t3.col1
    WHERE t2.col2 = t1.col1;
    But the problem is I have to use t1 in the FROM clause before I can use it in the WHERE clause. My question is how do I use t1 in Where clause without joining with t2 & t3?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    Do you really need to use a WITH clause?  It's hard to tell what you want to do just by looking at some code that doesn't do it, but it looks like you're trying to do this:
    SELECT  t2.col1,
            t3.col1,
            t3.col2
    FROM    t2
    JOIN    t3  ON t2.col1 = t3.col1
    WHERE   t2.col2 IN (
                           SELECT  col1
                           FROM    tab1
    If you really did need a WITH clause, you could reference it like this
    with t1 AS
        Select col1
        FROM   tab1
    SELECT  t2.col1,
            t3.col1,
            t3.col2
    FROM    t2
    JOIN    t3  ON t2.col1 = t3.col1
    WHERE   t2.col2 IN (
                           SELECT  col1
                           FROM    t1
    Joining t1, like Alberto suggested, is another possibility, but be careful: if t1.col1 is not unique, you may get duplicate rows.

  • Can I write with a stylus using  pages?

    I would like to know if I can write with a stylus using pages on my ipad. Has anyone been able to do this? thank you.

    The Pages app does not support a stylus pen.

  • Can't chat with friends who use AIM unless .mac friends host group chat

    For some reason, I can only text chat with my friends who use iChat with AIM accounts. When my friends with .mac accounts are on iChat, we can use video conference and send pictures via text easily.
    The only way I can video conference with my AIM friends (and send pictures) is if the .mac friends host the chat. We've all made sure we're using the upgraded softwares, and we're all using iChat AV 3.1.8... We all have the correct preferences according to iChat help, as well as meet all requirements listed on the Apple site.
    I have found no record of anyone else having this problem, nor can I find anything that remotely relates to anything similar.
    What are we doing wrong??? Has anyone else experienced this?

    Ok,
    Can you tell me everyone's Upload and download speeds please ?
    http://www.ralphjohnsuk.dsl.pipex.com/page5.html#_speedtests
    Also how is each person connected to the Internet ?
    Modem > computer Or
    Modem > router > computer ?
    Can you list how the ports are opened or allowed in each device ?
    If I understand you correctly can you add the other screen name to the other computer's iChat and see if it is computer related.
    If you have done Port Forwarding then it is most likely this is to one computer. This would only allow one computer at your end to Video chat. (adding the other screen nmae should give you Video on both screen names). As you have changed the Login port to 443 for everyone you will be able to Text chat as this is below port 1024 which is where the ports need to opened if above this number.
    As File sharing (sending Pics is on Port 5190 and UDP protocol this has not been moved and would explain why it can not be done.
    8:14 PM Tuesday; July 10, 2007

  • My iphone5 can't pair with other phones using Bluetoth !, My iphone5 can't pair with other phones using Bluetoth !

    my iphone5 can't pair with other phones like nokia to transfer data using Bluetoth !

    Correct, as it is isn't a supported protocol of the iPhone.

  • Can't update master table when creating a materialized view log.

    Hi all,
    I am facing a very strange issue when trying to update a table on which I have created a materialized view log (to enable downstream fast refresh of MV's). The database I am working on is 10.2.0.4. Here is my issue:
    1. I can successfully update (via merge) a dimension table, call it TABLEA, with 100k updates. However when I create a materialized view log on TABLEA the merge statement hangs (I killed the query after leaving it to run for 8 hrs!). TABLEA has 11m records and has a number of indexes (bitmaps and btree) and constraints on it.
    2. I then create a copy of TABLEA, call it TABLEB and re-created all the indexes and constraints that exist on TABLEA. I created a materialzied view log on TABLEB and ran the same update....the merge completed in under 5min!
    The only difference between TABLEA and TABLEB is that the dimension TABLEA is referenced by a number of FACT tables (by FKs on the FACTS) however this surely should not cause a problem. I don't understand why the merge on TABLEA is not completing...even though it works fine on its copy TABLEB? I have tried rebuilding the indexes on TABLEA but this did not work.
    Any help or ideas on this would be most appreciated.
    Kind Regards
    Mitesh
    email: [email protected]

    Thats what I thought, the MVL will only read data that has changed since it was created and wont have the option to load in all the data as though it was made before the table was created.
    From what I have read, the MVL is quicker than a Trigger and I have some free code that prooved to work from a MVL using it as a reference to know what records to update. There is not that much to a MVL, a record ID and type of update, New, Update or Delete.
    I think what I will have to do is work on a the same principle for the MVL but use a Trigger as this way we can do a full reload if required at any point.
    Many thanks for your help.

  • Issue with fast refresh on a materialized view

    Hi,
    Oracle DB version is 10.2.0.3
    We have a matierialized view created using this script. We have materialized view logs on these six tables.
    By default, it is set to ON COMMIT .
    When a batch job is run every morning (usually 100-200 records) we set it to ON DEMAND and then bring it back to ON COMMIT. It takes around 1-2 minutes.
    If the batch is unusually big, like say 100,000 it takes more than 5 hours to put it back on ON COMMIT. (We analyze the schema (GATHER STALE) before refreshing the MV.) Trace shows deletes taking a long time.
    When I see a big batch, I usually drop the view and recreate it with indexes (there is also a context index). Takes 30 mins to do the whole thing.
    I tried refreshing it COMPLETE when the num of rows is high but it still takes more than 2 hours..(I killed it)
    Is there any way to speed things up without dropping and recreating the MV ?
    thanks
    Mat view creation script:
    CREATE MATERIALIZED VIEW WCC_INTERNAL_SEARCH_M
    TABLESPACE ICV_TS_WCC_DATA
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FAST ON COMMIT
    WITH ROWID
    AS
    SELECT orgname.ROWID orgname_rowid,
    cnt.ROWID cnt_rowid,
    locgrp.ROWID locgrp_rowid,
    cntry.ROWID cdcntry_rowid,
    addrgrp.ROWID addrgrp_rowid,
    addr.ROWID addr_rowid,
    cnt.cont_id cont_id,
    decode(cntry.name,'US',substr(addr.postal_code,1,5),addr.postal_code) postal_code,
    cntry.name country,
    UPPER(addr.addr_line_one) addr_line_one,
    UPPER(addr.addr_line_two) addr_line_two,
    UPPER(addr.addr_line_three) addr_line_three,
    UPPER(addr.CITY_NAME) city_name,
    UPPER(cnt.CONTACT_NAME) display_name,
    UPPER(orgname.ORG_NAME) org_name,
    addr.prov_state_tp_cd
    FROM orgname,
    contact cnt,
    locationgroup locgrp,
    cdcountrytp cntry,
    addressgroup addrgrp,
    address addr
    WHERE locgrp.cont_id = orgname.cont_id
    AND locgrp.cont_id = cnt.cont_id
    AND addrgrp.location_group_id = locgrp.location_group_id
    AND addr.country_tp_cd = cntry.country_tp_cd
    AND addr.address_id = addrgrp.address_id
    AND cnt.INACTIVATED_DT is null
    AND locgrp.END_DT is null
    AND orgname.END_DT is null
    AND cnt.person_org_code = 'O'
    AND cntry.lang_tp_cd = 100
    AND locgrp.member_ind = 'Y'
    AND locgrp.loc_group_tp_code = 'A'
    ORDER by org_name,city_name,postal_code,country;

    This is the script that creates the preferences and then the context index.
    exec ctx_ddl.create_preference('STEM_FUZZY_PREF', 'BASIC_WORDLIST');
    exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_MATCH','AUTO');
    exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_SCORE','60');
    exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_NUMRESULTS','100');
    exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','STEMMER','AUTO');
    exec ctx_ddl.set_attribute('STEM_FUZZY_PREF', 'wildcard_maxterms',15000) ;
    exec ctx_ddl.create_preference('LEXTER_PREF', 'BASIC_LEXER');
    exec ctx_ddl.set_attribute('LEXTER_PREF','index_stems', 'ENGLISH');
    exec ctx_ddl.set_attribute('LEXTER_PREF','skipjoins',',''."+/-&');
    exec ctx_ddl.create_preference('ICV_WCC_INT_SEARCH_CTX_PREF', 'BASIC_STORAGE');
    exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'I_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
    exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'K_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
    exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'N_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
    exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'I_INDEX_CLAUSE','tablespace ICV_TS_CTX_IDX compress 2');
    exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'P_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
    exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'R_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
    CREATE INDEX WCC_INT_SEARCH_CTX_I1 ON WCC_INTERNAL_SEARCH_M
    (ORG_NAME)
    INDEXTYPE IS CTXSYS.CTXCAT
    PARAMETERS('Wordlist STEM_FUZZY_PREF
    LEXER LEXTER_PREF
    STORAGE ICV_WCC_INT_SEARCH_CTX_PREF');
    DB is 10.2.0.3

  • Can OGG capture change data set from Oracle Materialized Views ?

    Hi Gurus,
    We have 3 DB .
    1st one is for application . 2nd one is staging where data will come via Materialized Views i.e. we have MView log on DB_1 and have MView on DB_2 . MViews are getting refreshed incrementally everday .
    Now a new requirement has come so we need to pass the data from DB_2 to a new database DB_2 .
    If OGG can capture and replicate incremental data from Miews then we can go along with OGG .
    Can any one confirm the above ?
    Thanks,
    Pujan

    Hi Pujan,
    Yes. There are some restrictions mentioned in the section Limitations of support for materialized page 8 of the Oracle Installation and Setup Guide 11g Release 1 found here:
    http://www.oracle.com/technetwork/middleware/goldengate/documentation/index.html
    Good luck,
    -joe

Maybe you are looking for