Dropping base table of materialized view

HI please let me know what happens if i drop the base table of a materialized view? does the MV remain valid with data?

Hi,
Well, it's easy to test yourself.
SQL> select count(*) from t1;
  COUNT(*)
       100
SQL> desc t1
Name                                      Null?    Type
ID                                                 NUMBER(10)
SQL> create materialized view t1_mv as select * from t1;
Materialized view created.
SQL> select count(*) from t1_mv;
  COUNT(*)
       100
SQL> drop table t1 purge;
Table dropped.
SQL> select count(*) from t1_mv;
  COUNT(*)
       100
SQL> desc t1_mv
Name                                      Null?    Type
ID                                                 NUMBER(10)
SQL> select object_type, status from user_objects where object_name = 'T1_MV';
OBJECT_TYPE         STATUS
TABLE               VALID
MATERIALIZED VIEW   INVALID
SQL> select * from t1_mv where rownum < 5;
        ID
         1
         2
         3
         4
SQL>I think the answer is very clear.
Asif Momen
http://momendba.blogspot.com

Similar Messages

  • Convertion of Base tables to Material views while executing dbms_refreshes

    Hi all,
    I have a typical type of problem. We have a daily task of database activities like monitoring the space, refreshing Material views etc and currently using While doing refreshing the materialized views (using dbms.refresh) All master tables are become MV's in the database.This is a serious issue has to be solved asap.
    Also I find the materialized views got some data's in it. Now I want to get my master tables back to original.
    I have an idea to drop all the respective base tables, materialized view and recreate the same once again.
    But Is there any other alternate method there to get back my materialized views converted to base tables???
    Can someone help me how to do the same????
    Thanks in advance.
    Regards
    Dinesh

    While doing refreshing the materialized views (using dbms.refresh)
    All master tables are become MV's in the database?????
    So strange that I'd say that's not possible. How did you check that ? and which command did you execute exactly ?

  • Updating base table with Materialized View's data

    Hi,
    In order to update base table with MVs data, I am trying real time data transfer between two databases. One is Oracle 8i and other is Oracle 9i. I have created an updatable MV in 9i on a base table using database link. The base table is in 8i. Materialized View log is created in 8i on base table. MV has to be associated to some replication group, but I am not able to create replication group in 9i to which MV has to be associated. The required packages are not installed.
    Replication packages are to be used to create replication group are :
    /*Create Materialized View replication group*/
    BEGIN
    DBMS_REPCAT.CREATE_MVIEW_REPGROUP (
    gname => 'TEST_MV_GRP',
    master => 'TEST_DATA_LINK',
    propagation_mode => 'ASYNCHRONOUS');
    END;
    But above block is giving error.
    Can anyone suggest how to resolve this, or are there any other approaches (by not using replication packages) to update base table with MVs data ?
    Thanks,
    Shailesh

    Yes, I created link between two databases and was able to update tables on 8i from 9i database using that link.
    The error I am getting while creating replication group is :
    ORA-06550
    PLS-00201 : identifier 'SYS.DBMS_REPCAT_UTL2@'TEST_DATA_LINK' must be declared
    ORA-06550
    PLS-00201 : identifier 'SYS.DBMS_REPCAT_UNTRUSTED@'TEST_DATA_LINK' must be declared
    ORA-06512 : at "SYS.DBMS_REPCAT_UTL", line 2394
    ORA-06512 : at "SYS.DBMS_REPCAT_SNA_UTL", line 1699
    ORA-06512 : at "SYS.DBMS_REPCAT_SNA", line 64
    ORA-06512 : at "SYS.DBMS_REPCAT", line 1262
    Is there any other approach which can be used to update base table with MVs data instead of using replication packages ?
    Thanks,
    Shailesh

  • Table and Materialized View in different namespaces?

    I've just faced something completly new for me. It appears that there are two objects with the same name and owner. Table and Materialized View have the same names and when I look into system dictionary I can se sth. like that:
    OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE NAMESPACE
    USER_A USER_TABLE 159381 159381 TABLE 1
    USER_A USER_TABLE 159382 MATERIALIZED VIEW 19
    (I couldn't find how to write above with const length font).
    Two object in different namespace? I thought that Tables and Materialized Vievs have the same namespace.
    Can you please tell me how can I create objects to achieve above result? I would also be grateful if you tell me where to find that topic in documentation.

    Perfectly normal.
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    no rows selected
    SQL>
    SQL> create materialized view test_mv
      2  as
      3  select sysdate from dual;
    Materialized view created.
    SQL>
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    OBJECT_NAME                                        OBJECT_TYPE
    TEST_MV                                            TABLE
    TEST_MV                                            MATERIALIZED VIEW
    SQL>
    SQL> drop materialized view test_mv;
    Materialized view dropped.
    SQL>
    SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
    no rows selected
    SQL>

  • Truncate table and materialized view log

    I user oracle 10 R2
    I have a table and on that table a materialized view log.
    I execute in a pl/sql procedure:
    1) execute immediate('drop materialized view log on tab1');
    then:
    2) execute immediate('truncate table tab1');
    3) Now I insert a lot of records in tab1
    4) execute immediate('create materialized view log on tab1 WITH rowid INCLUDING NEW VALUES');
    When I create the materialized view log I recieved this message:
    ora32321: refresh fast on tab2 unsupported after detail table truncate
    Why?

    Refresh fast after truncate operation on container table is not supported, regardless the container table is or is not partitioned.
    Perform a refresh complete.
    ORA-32321 :
    Cause:     A detail table has been truncated and no materialized view
         supports fast refersh after a detail table has been truncated
    Action:     Use REFRESH COMPLETE. Note: you can determine why your
         materialized view does not support fast refresh after TRUNCATE
         using the DBMS_MVIEW.EXPLAIN_MV() API.

  • Oracle equals_path condition NOT working with table and materialized view

    The user i am using is xdb with dba role.
    1.When i try to use the statement
    SELECT PATH FROM xdb.path_VIEW
    WHERE
    EQUALS_PATH(res, '/home/OE/PurchaseOrders/2002')=1
    the result is
    /home/OE/PurchaseOrders/2002
    2. When i drop the path_view and recreated it like materialized view with statement
    create MATERIALIZED view path_view as
    select /*+ ORDERED */ t2.path path, t.res res,
    xmltype.createxml(xdb.xdb_link_type(NULL, r2.xmldata.dispname, t.name,
    h.name, h.flags, h.parent_oid, h.child_oid),
    'http://xmlns.oracle.com/xdb/XDBStandard.xsd', 'LINK') link,
    t.resid
    from ( select xdb.all_path(9999) paths, value(p) res, p.sys_nc_oid$ resid,
    p.xmldata.dispname name
    from xdb.xdb$resource p
    where xdb.under_path(value(p), '/', 9999)=1 ) t,
    TABLE( cast (t.paths as xdb.path_array) ) t2,
    xdb.xdb$h_link h, xdb.xdb$resource r2
    where t2.parent_oid = h.parent_oid and t2.childname = h.name and
    t2.parent_oid = r2.sys_nc_oid$
    then the equals_path condition STOP working !!!
    3. The same experiment, but i recreate it like table
    create table path_view as .... using the rest of the statement ...
    Can someone help me to understand why equals_path is NOT working on table and materialized view !

    Thanks Jonah. I was under the impression that I already had it but seems like it has to be a direct priv - thru a role doesn't work.
    I granted the reqd privs and then it worked fine. Thx for your help!

  • Updating a Base Table through a View having UNPIVOT function.

    Hi,
    I have a requirement of updating a Base Table through a View.
    This View has the query using a UNPIVOT function for displaying the columns of the Base tables in rows.
    I need to update/insert into/delete the Base Table by accessing the View (The user doesn't have an access to the Base Table, hence the DML's on the View).
    Following is the table I've created:-
    CREATE TABLE PERSON_DETAILS
      PID            VARCHAR2(10 BYTE),
      FIRSTNAME      VARCHAR2(1000 BYTE),
      LASTNAME       VARCHAR2(1000 BYTE),
      PHONENUMBER    VARCHAR2(1000 BYTE),
      ADDRESS1       VARCHAR2(1000 BYTE),
      ADDRESS2       VARCHAR2(1000 BYTE),
      COUNTRY_CODE   VARCHAR2(1000 BYTE),
      LANGUAGE_CODE  VARCHAR2(1000 BYTE),
      EMAIL          VARCHAR2(1000 BYTE)
    )The sample values are inserted in this table through the below script:-
    insert into person_details values ('1','XYZ','ABC','1234567890','India','Asia','IN','EN','[email protected]');
    insert into person_details values ('2','XYZ2','ABC2','1234567890','India','Asia','IN','EN','[email protected]');The code for the view is as below:-
    CREATE OR REPLACE FORCE VIEW PERSON_DETAILS_VIEW
       PID,
       CD_NAME,
       CD_VALUE
    AS
       SELECT "PID", "CD_NAME", "CD_VALUE"
         FROM person_details UNPIVOT INCLUDE NULLS (cd_value
                             FOR cd_name
                             IN  (firstname AS 'First Name',
                                 lastname AS 'Last Name',
                                 phonenumber AS 'Phonenumber',
                                 address1 AS 'address1',
                                 address2 AS 'address2',
                                 country_code AS 'Country Code',
                                 language_code AS 'Language Code',
                                 email AS 'Email') );Below are the values from the view:-
    PID CD_NAME         CD_VALUE
    1    First Name       XYZ
    1    Last Name       ABC
    1    Phonenumber  1234567890
    1    address1         India
    1    address2         Asia
    1    Country Code   IN
    1    Language Code EN
    1    Email               [email protected]
    2    First Name       XYZ2
    2    Last Name       ABC2
    2    Phonenumber  1234567890
    2    address1         India
    2    address2         Asia 
    2    Country Code   IN
    2    Language Code EN
    2    Email               [email protected] user would fire some statement like below:-
    update person_details_view
    set cd_value = 'US' where CD_NAME = 'IN'The above statement should update the base table PERSON_DETAILS.
    I understand I can write an INSTEAD OF trigger but I do not know what logic to write in the trigger so that the requirement gets fulfilled.
    My Oracle Version
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0    Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionAny help would be highly appreciated.
    Thank You,
    Ankit Khare.
    Edited by: Ankit_Khare84 on Jun 28, 2012 2:47 PM

    it is definitively possible with an instead of trigger.
    for Example:
    create or replace
    TRIGGER ioft_person
    INSTEAD OF UPDATE
    ON person_details_view
    FOR EACH ROW
    declare
    firstname1  person_details.firstname%type;
    BEGIN
                  SELECT firstname_new into firstname1
                  FROM   (SELECT pid, cd_name, cd_value
                          FROM  
                                  select * from person_details_view where (pid, cd_name) not in (select :new.pid, :new.cd_name from dual)
                                  union all
                                  select :new.pid, :new.cd_name, :new.cd_value from dual
                  PIVOT  ( max(cd_value) AS new FOR (cd_name) IN
                                                          ('First Name' AS firstname,
                                                            'Last Name' as lastname,
                                                            'Phonenumber' as phonenumber,
                                                            'address1' as address1,
                                                            'address2' AS address2,
                                                            'Country Code' as country_code,
                                                            'Language Code' as language_code,
                                                            'Email' as email
                  )  where pid = :old.pid;
      UPDATE person_details
      SET firstname = firstname1
      WHERE pid = :old.pid;
    END ioft_role_perm;and than run
    update person_details_view
    set cd_value = 'X|X' where cd_name = 'First Name' and pid=1The logic is: you must convert back the view through pivoting

  • Need Advise on Global Temporary tables or Materialized views or Views

    Need advise on a plsql procedure working on.
    I had 6 tables having 200,000 rows in total intially,but will get added a maximum 20,000 rows daily by a batch process.
    I am writing a plsql code that takes an input ,for example customer_id, and is required to get all the data for that customer_id and
    had to do some complex calculation that includes stepwise validations before giving the output.Now while doing the logic it has the get the data for that customer_id from all the tables.
    There may be 100 records for that particular customer_id.
    I need advise on the below options.
    1.Use of global temporary tables get those 100 records and do the calculation part on that Global Temporary table.
    2.Use of Views or Materialized views.
    3.Using the Record Structures(like table types for those records) and then do the logic on them
    As Performance is the key point here i would like pull all the data at once into memory and then do the calculations instead of hitting the database many times, this is my main idea(correct me if am wrong).Also please advise if there are any other options
    I am using ORACLE 10G.
    Thanks
    Rede

    The approach that many advocate for here (including myself) is to do as much in SQL as possible. So, copying to GTTs or using record structures is probably not the solution you should be after.
    If you can provide the following details we may be able to steer you down the right path
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    Ideally try and re-create the problem, simplifying it as much as possible, without losing context. Use #1-#5 above as a base for posting your simplified problem here. Then we may be able to give you a solution specific to your problem.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Synonym problem with external table in materialized view

    I have a materialized view that includes selects on two external tables.
    However, no matter how I try to access the external tables, the creation fails with a "Synonym Translation Is No Longer Valid" (ORA-00980) error.
    This happens even when I replace the tablename with the full table name, including the link.
    I can create a view just fine, but if I then try something like CREATE MATERIALIZED VIEW mvw_my_view AS SELECT * FROM vw_my_view (where vw_my_view is the view in question), it still throws the Synonym Translation exception.

    00980, 00000, "synonym translation is no longer valid"
    // *Cause: A synonym did not translate to a legal target object. This
    //         could happen for one of the following reasons:
    //         1. The target schema does not exist.
    //         2. The target object does not exist.
    //         3. The synonym specifies an incorrect database link.
    //         4. The synonym is not versioned but specifies a versioned
    //            target object.
    // *Action: Change the synonym definition so that the synonym points at
    //          a legal target object.It is really, Really, REALLY difficult to fix a problem that can not be seen.
    use COPY & PASTE so we can see what you do & how Oracle responds.

  • List the base tables of a view

    Hi All,
    I have a view but I do not have any information about the base tables and the query that was used to set up this view. Is there a way to atleast list the base tables on which the view was created!
    Thanks in advance!
    ~

    SQL> desc user_source
    Name Null?
    Type
    NAME
    ARCHAR2(30) - > Name of the View.
    TYPE
    ARCHAR2(12)
    LINE
    NUMBER
    VARCHAR2(4000) -> will give you the text to
    create the View.-----------------------------------------------------------------------------------------------------------------------
    For some reason the view I have is not listed in the NAME ..

  • User_catalog - object listed as both 'TABLE' and 'MATERIALIZED VIEW'

    SELECT * FROM USER_CATALOG ORDER BY OBJECT_NAME
    returns ...
    OBJECT_NAME              OBJECT_TYPE       
    BLOBBY                   SYNONYM           
    BONUS                    TABLE             
    DEPT                     TABLE             
    EMP                      TABLE             
    EMPLOYEES                SYNONYM           
    EMPWITHDEPT              MATERIALIZED VIEW 
    EMPWITHDEPT              TABLE             
                             ^^^^^^^^^^^^Any ideas to show only the 'MATERIALIZED VIEW' row for the above query?
    Thanks in advance,
    Mike Norman

    So, I would need some sort of logic to
    check if the OBJECT_NAME from user_objects
    is present in user_snapshots print 'MATERIALIZED VIEW'
    otherwise take the OBJECT_TYPE from user_objects -
    some sort of DECODE?

  • Maintaining Stock Availibility : physical table or materialized view  ?

    Hi All,
    We have typical Order processing application where I should maintain
    stock availibility => Order is rejected if Stock is not available. The number of orders is 1000 perday, 22 branch, using VPD. 10 users each branch.
    We are really tempted to use JUST view /materialized view to maintain stock position. (where traditionally we use a phiysical table for this, updated after insert/update/delete of transactions)
    So the view will be like this :
    Create View Stock AS
    Select Prod.Code, Prod.beginning_balance,
    ( SELECT Sum (Qty) from Purchase Where ProdCode = prod.code ...) AS Purchase,
    ( SELECT Sum (Qty) from Order Where ProdCode = prod.code ...) AS Order,
    From Products Prod
    So to get the stock availability for a particular product :
    Select Beginning_balance + Purchase - Order from Stock Where Code = ...
    Please give comments, will this work with good performance ?
    Or has anybody done like this in their application ?
    Thank you for your help,
    xtanto

    If we're talking about a materialized view, I assume you'd do incremental fast refreshes. If we're talking about 1000 transactions a day, I wouldn't be at all concerned. Growth of the transaction table ought to have no impact on the speed with which the materialized view could be refreshed.
    I can't think of any blocking issues that would arise from using a materialized view that wouldn't occur if you were updating a separate physical table. The timing might be slightly different, but Oracle's multi-version read consistency ought to work the same either way, hence you ought not ever block.
    Justin

  • Alter the main tables of materialized views

    Hi
    I want to add a new column to the main table of a materialized view.Can anyone let me know,what are the steps I need to take care on materialized views,In addition to recompiling dependent objects?

    PER_SPECIAL_INFO_TYPES: This table holds the definitions of SITs that are available to each Business Group. Each special information type is a user defined structure for the personal analysis key flexfield. The name of the special information type is the same as the name of the corresponding key flexfield structure.
    PER_SPECIAL_INFO_TYPES_V : This table has the Employee's SIT info. A supplementary view used to simplify forms coding
    PER_SPECIAL_INFO_TYPES_V2 : A supplementary view used to simplify forms coding.

  • Performance difference between tables and materialized views

    hi ,
    I created a materialized view on a query that involves partition table in it.
    When i used the same query and created a table out of it <create table xyz as select * from (the query)> ,the table got created quickly.
    So does that mean performance wise creating table is faster than creating/refreshing the materialized view ?or is that due to the refresh method i use ?Currently i use a complete refresh

    I created a materialized view on a query that involves partition table in it.
    When i used the same query and created a table out of it <create table xyz as select * from (the query)> ,the table got created quickly.
    So does that mean performance wise creating table is faster than creating/refreshing the materialized view ?or is that due to the refresh method i use ?Currently i use a complete refresh Well, for starters, if you created the materialized view first and then the standard table, the data for the second one has already been fetched recently and so will reduce your I/O due to caching, and will therefore be quicker. There are also other factors such as the materialized view creating other internal bits that are required to allow for refreshes to be done quickly, such as the primary key etc which you haven't created on your second creation.
    What you have shown is that two completely different statements running at different times, appear to operate with different speed. It is not a comparison of whether the materialized view is slower or quicker than the create table statement.

  • 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

Maybe you are looking for

  • My ipod was stolen help!!

    one of the store ipod people told me i can get it back reason i have my warrenty till the end of this year i want to kno if thats thru and how?

  • LR 1.4.1 and Camera Raw 4.4.1 - Same engine?

    I'm using LR and CS2 and can't use camera raw 4.4.1. Are the develop module in LR 1.4.1 and camera raw 4.4.1 the same thing? I use Nikons and NEF files and convert to DNG with Adobe DNG converter 4.1.

  • How to balance exposure in multiple images?

    I will be shooting a series of photos that inludes a gray card in each image. How can I use Lightroom to obtain the same exposure in each image relative to the gray card?

  • Yahoo toolbar covers my firefox menues

    Installed Mozilla on my new computer from download. Install included Yahoo tool bar. Don't want Yahoo. Can't remove Yahoo because it covers my Firefox menue items. == This happened == Every time Firefox opened == When I installed anew copy of Firefox

  • Multiple Validation Checks

    Hi, I have to do multiple around 2000 validation/edit checks ifor webforms in Hyperion planning 11.1.1.2. please suggest how I acn do that?