Moving all Materialized View and logs at schema level using data pump

Hi Experts,
Please help me on how can I exp/imp all Materialized Views andMV logs (as these are local MVs) only of complete schema to other database. I want to exlude everything else.
Regards
-Samar-

Use DBMS_METADATA. Create the following SQL script:
SET FEEDBACK OFF
SET SERVEROUTPUT ON FORMAT WORD_WRAPPED
SET TERMOUT OFF
SPOOL C:\TEMP\MVIEW.SQL
DECLARE
    CURSOR V_MLOG_CUR
      IS
        SELECT  DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW_LOG',LOG_TABLE) DDL
          FROM  USER_MVIEW_LOGS;
    CURSOR V_MVIEW_CUR
      IS
        SELECT  DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW',MVIEW_NAME) DDL
          FROM  USER_MVIEWS;
BEGIN
    DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE);
    FOR V_REC IN V_MLOG_CUR LOOP
      DBMS_OUTPUT.PUT_LINE(V_REC.DDL);
    END LOOP;
    FOR V_REC IN V_MVIEW_CUR LOOP
      DBMS_OUTPUT.PUT_LINE(V_REC.DDL);
    END LOOP;
END;
SPOOL OFFIn my case script is saved as C:\TEMP\MVIEW_GEN.SQL. Now I'll create a mview log and mview in SCOTT schema and run the above script:
SQL> CREATE MATERIALIZED VIEW LOG ON EMP
  2  /
Materialized view log created.
SQL> CREATE MATERIALIZED VIEW EMP_MV
  2  AS SELECT * FROM EMP
  3  /
Materialized view created.
SQL> @C:\TEMP\MVIEW_GEN
SQL> Running script C:\TEMP\MVIEW_GEN.SQL generated a spool file C:\TEMP\MVIEW.SQL:
  CREATE MATERIALIZED VIEW LOG ON "SCOTT"."EMP"
PCTFREE 10 PCTUSED 30 INITRANS
1 MAXTRANS 255 LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1       
MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL
DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"
WITH PRIMARY KEY EXCLUDING NEW VALUES;
  CREATE MATERIALIZED VIEW "SCOTT"."EMP_MV" ("EMPNO", "ENAME", "JOB", "MGR",  
"HIREDATE", "SAL", "COMM", "DEPTNO")
  ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 
INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576
MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE 
"USERS"
  BUILD IMMEDIATE
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE    
DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"
  REFRESH FORCE ON     
DEMAND
  WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
  USING ENFORCED
CONSTRAINTS DISABLE QUERY REWRITE
  AS SELECT "EMP"."EMPNO"                    
"EMPNO","EMP"."ENAME" "ENAME","EMP"."JOB" "JOB","EMP"."MGR"                    
"MGR","EMP"."HIREDATE" "HIREDATE","EMP"."SAL" "SAL","EMP"."COMM"               
"COMM","EMP"."DEPTNO" "DEPTNO" FROM "EMP" "EMP";
                               Now you can run this on other database. You might need to adjust tablespace and storage clauses. Or you can add more DBMS_METADATA.SET_TRANSFORM_PARAM calls to C:\TEMP\MVIEW_GEN.SQL to force DBMS_METADATA not to include tablespace or/and storage clauses.
SY.

Similar Messages

  • Materialized view excessive logging.  SOS

    The refresh of our materialized view is causing excessive logging. I altered the materialized view to NOLOGGING but it did not have any effect, not sure why?
    We either need to change the refresh time from 3 minutes to every 15 minutes(which is a bummer, data would be more stale) or give up on the materialized view.
    The quantity of archive logs has more than doubled since we adding this materialized view and the file system partition filed up last night, halting activity inside the database!
    Any suggestions?

    The refresh is not set for direct path inserts.Good. Now you have something you can change to help resolve the issue.
    The MV does not have any indexes.So the logging issue you describe is purely caused by deletes from, and inserts into the MV during a complete refresh.
    You can use the advice given by Alex above, and use atomic_refresh => false. Before you say it cannot be done because the users will not have access to the data during refresh, you might need to get creative. If you use query rewrite, for example, users would have access to data from the base tables while the MV is being refreshed. Their queries may be slower for a while, but they will still get data. If waiting 3 minutes or so is unacceptable for the queries that sneak in during a refresh, you can consider the following. Use query rewrite and have 2 materialized views, one of which can refresh while the other is available. After refreshing one, disable query rewrite on the older one.
    We cannot perform a fast refresh due to the query required to build the view.I'll take your word on it, although I have come across this situation many times where MVs that were thought to be impossible to fast refresh actually can be made to do it. Again, you might need to get creative. Sometimes you can do this by having MVs built on other MVs.
    Also, consider using MVs on prebuilt tables. You get additional control over how to refresh the MV this way. You can build your own custom refresh process that might help you do your own "fast refresh" by just applying the delta to your data (insert a few rows, update a few aggregates, perhaps). You can even do things like partition swapping so you can build your refreshed data in a separate table and then swap it with the MV partition (even if it is all in one partition).

  • Materialized view and Partition

    Hi,
    I want to discuss a scenario, with which i am dealing nowadays. there is only a single table (named livecdr ) has 22-23 fields and the records are updating in every sec (on daily basis) and in 24hrs livecdr contains approximately more than 2 crore records.
    Problem is that the query processing time is so slow due to large number of records and query is fetching records from a view created on livecdr table. I want to know the options, how the query would fetch these records in a short time. Firstly i did range partitioning on livecdr and then i created materlized view but the view didn't create on partition table and when i removed partitioning it was created. After view creation, query performance is much better. i also applied indexing on livecdr.
    Can you please tell me, whether this approach is okay or i am doing mistake. should i create partitioning on materialized view and how would i select records from view if partitioning would be applied on materialized view. Please guide me with best approaches.
    thankyou.

    Hello,
    Here is how I created partitioned table (monthly partitions) and partitioned mview on the table. This is just an example you might have to change the mview partitions from monhtly to yearly or quartely.
    CREATE TABLE live_cdr
       CALLID              VARCHAR2 (20),
       CD                  VARCHAR2 (25),
       CG                  VARCHAR2 (25),
       RE                  VARCHAR2 (25),
       OPC                 VARCHAR2 (12),
       DPC                 VARCHAR2 (12),
       STIME               VARCHAR2 (25),
       SDATE               DATE,
       ATIME               VARCHAR2 (25),
       ADATE               DATE,
       ETIME               VARCHAR2 (25),
       EDATE               DATE,
       schangeTime         VARCHAR2 (25),
       schangeDate         DATE,
       STATUS              VARCHAR2 (25),
       bucket              NUMBER (20),
       CIC                 NUMBER (20),
       charge              VARCHAR2 (30),
       ported              VARCHAR2 (30),
       jurisdiction_Info   VARCHAR2 (30),
       origLine_Info       CHAR (1),
       Variant             NUMBER,
       auto_inc            NUMBER
    PARTITION BY RANGE (EDATE)
      PARTITION LIVE_CDR_JAN_2009 VALUES LESS THAN (TO_DATE(' 2009-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        NOCOMPRESS, 
      PARTITION LIVE_CDR_FEB_2009 VALUES LESS THAN (TO_DATE(' 2009-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        NOCOMPRESS
    );Mview definition
    CREATE MATERIALIZED VIEW KLONDIKE.LIVE_CDR_MV
    LOGGING
    PARTITION BY RANGE (EDATE)
      PARTITION LIVE_CDR_MV_JAN_2009 VALUES LESS THAN (TO_DATE('20090201',
          'YYYYMMDD'))
        LOGGING
        NOCOMPRESS,
      PARTITION LIVE_CDR_MV_FEB_2009 VALUES LESS THAN (TO_DATE('20090301',
          'YYYYMMDD'))
        LOGGING
        NOCOMPRESS
    BUILD IMMEDIATE
    REFRESH COMPLETE
    START WITH SYSDATE
    NEXT SYSDATE  + 2 /24
    AS
    SELECT   DISTINCT (ic.callid) callid,
                      ic.CG,
                      ic.CD,
                      ic.RE,
                      ic.OPC,
                      ic.DPC,
                      ic.SDATE,
                      ic.STIME,
                      ac.ADATE,
                      ac.ATIME,
                      ec.ETIME,
                      ec.EDATE,
                      ec.STATUS
      FROM   live_cdr ic, live_cdr ac, live_cdr ec
    WHERE       ic.callid = ac.callid
             AND ic.callid = ec.callid
             AND ic.stime = ac.stime
             AND ic.stime = ec.stime
             AND ic.sdate = ac.sdate
             AND ic.sdate = ec.sdate
             AND ac.ADATE IS NOT NULL
             AND ec.EDATe IS NOT NULL
             AND ec.etime IS NOT NULL
             AND ic.CD IS NOT NULL
             AND ic.cg IS NOT NULL;Regards

  • Diff materialized view and view

    what is diff materialized view and view

    Check these documents please
    [Overview of Materialized Views|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#CNCPT411]
    [Overview of Views|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#i20690]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Updatable Materialized View and Master Table on same database

    Hi all,
    My first question - Is it possible to have an Updatable Materialized View and the associated Master Table located on the same database?
    This is the requirement scenario:
    One unique database D exists.
    A is a batch table. Only inserts are allowed on Table A.
    M is an updatable materialized view on Table A (Master). Only updates are allowed on M (no insert or delete).
    Requirement is to push updates/changes from M to A periodically and then get the new inserted records from A into M via a refresh.
    Is this possible? What other approaches are applicable here?

    John,
    My question is related to the implementation and setup of the environment as explained in the above example. How can I achieve this considering that I have created an updatable m-view?
    If possible, how do I push changes made to an updatable m-view back to it's master table when/before I execute DBMS_MVIEW.REFRESH on the m-view? What is the procedure to do this if both table and mview exist on the same database? Do I need to create master groups, materialized view refresh groups, etc.?
    One more thing.. Is there a way to retain changes to the m-view during refresh? In this case, only newly inserted/updated records in the associated table would get inserted into m-view. Whereas changes made to m-view records would stay as-is.
    Hope my question is directed well. Thanks for your help.
    - Ankit

  • Materialized view and Table

    Dear Friends,
    One quick question ..
    If the table name and materialized view name is same does truncating the data from table truncates materialized view too ?
    Thanks/

    CREATE TABLE "ABBREVIATION"
    "ABBREVIATIONID" VARCHAR2(36 BYTE),
    "ABBREVIATIONCODE" VARCHAR2(30 BYTE),
    "ABBREVIATIONTEXT" VARCHAR2(128 BYTE),
    "CREATIONDATE" DATE,
    "CREATEDBYLOGINID" VARCHAR2(36 BYTE),
    "LASTMODIFIEDDATE" DATE,
    "LASTMODIFIEDBYLOGINID" VARCHAR2(36 BYTE),
    CONSTRAINT "PK_ABBREVIATION1" PRIMARY KEY ("ABBREVIATIONID") TABLESPACE "KUMAR" ENABLE
    CREATE MATERIALIZED VIEW "ABBREVIATION" ("ABBREVIATIONID", "ABBREVIATIONCODE", "ABBREVIATIONTEXT", "CREATIONDATE", "CREATEDBYLOGINID", "LASTMODIFIEDDATE", "LASTMODIFIEDBYLOGINID") TABLESPACE "KUMAR" NEVER REFRESH
    AS
    SELECT "ABBREVIATION"."ABBREVIATIONID" "ABBREVIATIONID",
    "ABBREVIATION"."ABBREVIATIONCODE" "ABBREVIATIONCODE",
    "ABBREVIATION"."ABBREVIATIONTEXT" "ABBREVIATIONTEXT",
    "ABBREVIATION"."CREATIONDATE" "CREATIONDATE",
    "ABBREVIATION"."CREATEDBYLOGINID" "CREATEDBYLOGINID",
    "ABBREVIATION"."LASTMODIFIEDDATE" "LASTMODIFIEDDATE",
    "ABBREVIATION"."LASTMODIFIEDBYLOGINID" "LASTMODIFIEDBYLOGINID"
    FROM "ABBREVIATION" "ABBREVIATION";
    If I create a mv with a differnent name than that of a table does the truncation of data in table results in truncation of MV too ?

  • Materialized View and I_SNAP$ Indexes

    Hello Everybody,
    At the time of doing REFRESH of the Materialized View, we are getting error like -
    SQL> EXECUTE DBMS_MVIEW.REFRESH('MV_TEST.MY_VIEW,'CF');
    BEGIN DBMS_MVIEW.REFRESH('MV_TEST.MY_VIEW,'CF'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (MV_TEST.I_SNAP$_FIN_RESULT_EXPENSE1) violated
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2545
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2751
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2720
    ORA-06512: at line 1
    I tried to drop and recreate the index I_SNAP$_FIN_RESULT_EXPENSE1 but it didn’t helped.
    Later I dropped the index I_SNAP$_FIN_RESULT_EXPENSE1 and refreshed the materialized view and it was successful (obvious). But when I tried to recreate the index, I got the following error –
    SYS_OP_MAP_NONNULL("FIN_MULT"), SYS_OP_MAP_NONNULL("FIN_CD"))
    ERROR at line 8:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    When I look at the value of SYS_OP_MAP_NONNULL('FIN_CD'), it seems to be unique.
    SQL> select SYS_OP_MAP_NONNULL('FIN_CD') from dual;
    SYS_OP_MAP_NONNULL('FIN_CD’)
    46494E5F5650545F4C564C5F335F434400
    My questions are:
    1.     Why are the indexes (I_SNAP$_*) automatically created for?
    2.     What is the purpose of these (I_SNAP$_*) indexes?
    3.     What harm can be there if we drop these (I_SNAP$_*) indexes?
    4.     Why it is complaining about the Duplicate records / Uniqueness?
    5.     How to know where exactly the problem is in this case?
    6.     What is the solution for this problem? How to recreate these indexes successfully?
    Thanks!

    Hello Rafi,
    I don't have any MLOG$_<table> in the database, After connecting as SYS -
    SQL> select tname from tab where tname like '%MLOG%';
    TNAME
    MLOG_REFCOL$
    MLOG$
    C_MLOG#
    SQL> select count(*) from mlog$;
    COUNT(*)
    0
    I am not using Replication here -
    SQL> select tname from tab where tname like '%RUPD%';
    no rows selected
    Why you think that granting SELECT access to MLOG$_* tables will solve this issue?
    Thanks,
    Roopesh

  • Materialized view and snapshot

    Hi gurus,
    Could you please tell me what is the difference between materialized view and snapshot.
    Regards
    Koustav

    A snapshot, is in general terms, a picture, a click of a camera, an image that captures the position/state of something at sometime.
    Snapshot in a database can take many points of view.
    Materialized view (MV) is an object in Oracle database. It "materializes" a view, by taking a snapshot, of the view when you actually create the MV, and preserve it for future use. It can be refreshed in several available ways.
    A view doesn't occupy any space, a MV does.
    HTH,
    Aswin.

  • Materialized View and Ord Media questions

    Hey Guys,
    My first question is on the use and creation of materialized views which i have previously done using TOAD. The question that i have is where/if can i visually see the constraints that are on a materialized view and where is the information for "next refresh" times placed?
    Question two is about viewing informaiton on ord media objects that are stored. Previously, i had the ability to double click one of these elememts in the data view and see the information related to that instance of the ord media object, but the SQL developer does not seem to have this ability??
    Thanks in advance.

    Thanks Kris,
    The reason that i asked about the constraints on MV is because when you create a materialized view over a db link with primary key, it will place a not null constraint on every column. This is obviously no good because some rows are bound to contain nulls and these need to be removed and updated before it will work!
    As for the ord objects, it just makes it a little easier for testing to see what they are :).
    Anyway, its looking great and i hope these features will be in the next release?
    Cheers David

  • Materialized view and policies

    Hello,
    We created an materialized view and on this view why created a policy.
    SYS.DBMS_RLS.ADD_POLICY
    Now we added some values to the MV via drop MV and create MV.
    The policy on this MV is gone after the drop statement.
    Is there away to secure this?
    Thanks,
    Remco

    Why are you dropping and re-creating the materialized view in the first place? That's not something that should ever happen in a live system. You should just be refreshing the data in the materialized view, in which case the privileges & policies associated with the materialized view would be retained. It's no different than dropping and re-creating a table that has a policy associated with it-- you'd have to re-apply the policy after re-creating the table.
    Theoretically, I suppose you could create a DDL trigger that would throw an error if you tried to drop an object with an associated policy. Fixing your approach, though, so that you're not dropping & re-creating objects is going to be the better long-term solution.
    Justin

  • I moved all my photos and videos from iPhoto to external hard drive and now can't play any videos. Please help!!!

    I moved all my photos and videos from iPhoto to external hard drive, then totaly formated my macbook and now trying to play videos of external hard drive, but they wont play and they in "quicktime containers" and really small in size (50 - 150 Kb). Please Help!!! My misuse will kill me if find out that we have no more videos from our honeymoon...

    I moved all my photos and videos from iPhoto to external hard drive, then totaly formated my macbook and now trying to play videos of external hard drive, but they wont play and they in "quicktime containers" and really small in size (50 - 150 Kb). Please Help!!! My misuse will kill me if find out that we have no more videos from our honeymoon...
    You may need to prepare yourself for a "World of Hurt" from your wife...
    Since the average 0.9 megapixel JPEG photo file of normal graphic complexity stored at a high quality compression setting is 125-135 KBs in size, I would have to assume any QT video files you created of more than a fraction of a second in duration were most likely saved as "reference" files to only be 50-150 KBs. Basically, a reference file is q QT (MOV) file that tells a video player how to play data that is still stored in its original source file container(s). For instance, you could trim and merge a number of files together and save the result as a "reference" file that takes up very little room on your hard drive. Or, you could post fles to a server and create a "reference" file that is small enough to be sent as an email attachment that plays the uploaded data on someone else's computer as long as they are connected to the Internet. Unfortunately, for these reference files to work, all of the resources referenced within the file must continue to exist in their proper locations in order to be found and played by the reference. Since you did not indicate what "but they won't play" really means here or how you actually "moved" your iPhoto library files to the external drive, I can only make some "educated guesses" at this point. (BTW: for future reference, iPhoto has a built-in function that allows you to copy your library to one or more back-up locations and then connect to them by default when iPhoto opens or switch source libraries at will within the opened application.)
    If you created reference files and saved them to an external drive, you should be getting an error message telling you the app needs to know where the source files are located so the reference file can re-connect to the resource data. If the original files were also saved, then simple navigate to the source files in oder to tell the app where they are now located. If the source files were deleted as part of the reformatting process, then you are up the proverbial creek whithout a paddle with little or no hope of doing anything about this issue. (I.e., reformatting and then re-installing a system drive usually means you would have little hope of recovering the specific "lost" data you want as there is always a good chance that some of the data segments were overwritten during the process.)

  • I have two Apple ID's.  How do I move all the songs and videos that I bought using Apple ID "A" over to Apple ID "B".  I plan to use Apple ID "B" from here on out.  Thanks

    I want to move all the songs and videos that I purchased using Apple ID "A" over to Apple ID "B". 
    I plan to use Apple ID "B" from here on out. 
    Thanks to all. 
    I'm using Macbook Air
    OS X ver 10.9.3

    You can't do this yourself; if desired, you can ask the iTunes Store staff if they'll do it, but they probably won't.
    (108496)

  • I accidentally turned the Bluetooth of my Mac all in one and now I can't use the mouse anymore so I don't know I can reactivate the Bluetooth again!! Please help!

    I accidentally turned the Bluetooth off from my Mac all in one and now I can't use the mouse anymore so I don't know I can reactivate the Bluetooth again!! Please help!
    Aisha05

    Try resetting the SMC.
    Barry

  • Got an email stating my Creative Cloud Membership ends tonight, yet I'm all paid up and the card I'm using to pay for it is good.  I have two very important projects going on and can't afford to have CC go down.  Please help!

    got an email stating my Creative Cloud Membership ends tonight, yet I'm all paid up and the card I'm using to pay for it is good.  I have two very important projects going on and can't afford to have CC go down.  Please help!

    You have 3 CC under same Adobe ID out of which one purchased on has expired, you are getting notification due to this.
    Creative Cloud Photography plan (one-year)
    Desktop Subscription
    Mar 30, 2015
    The other two are active, however it is advisable to have one CC under one Adobe ID.
    Regards
    Rajshree

  • I have a hp photosmart c7280 all in one and i get a message that says "pump motor stalled.

    I have an HP photosmart C7280 All in One and I get a message that says pump motor stalled.  I have done everything from resetting and turning it off.  I have checked to make sure that there is not any paper jam.  It makes a clicking sound after it has been reset and then the message "pump motor stalled" pops up.  Any suggestions or should I just toss and buy new???  It is only three years old but it is out of warranty.

    You might try the suggestions in this post.  There is also a post here that reports success.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

Maybe you are looking for