Altering Views in Oracle 10.2

Hi,
I have a requirement that we need to change code of some views before running some daily batches (part of the code is not required for running the daily batches) and then revert back to the original code once the daily batches finish. Instead of using alter view command daily, I though about creating a new view for the modified code which will be used for running the batches and just swap the names of the two views before running the daily batches and then revert back after batches completion.
Any suggestion on this?
Thanks,
Younis

Instead of modifying the view, why not have 2 different Views and a Synonym for the "correct" view. The Application Code references only the synonym and you have "pre-Batch" and "post-Batch" commands to drop and recreate the Synonym to point to the "correct" view. That way, no objects get invalidated !
SQL> create table TAB_A as
  2  select 'HEMANT' as owner, object_name, object_type, created
  3  from user_objects;
Table created.
SQL> create table TAB_B as
  2  select owner, object_name, object_type, created
  3  from dba_objects;
Table created.
SQL> create view UNIONALL_VIEW as select * from TAB_A union all select * from TAB_B;
View created.
SQL> create view UNION_VIEW  as select * from TAB_A union select * from TAB_B;
View created.
SQL> select count(*) from UNIONALL_VIEW;
  COUNT(*)
     46290
SQL> select count(*) from
  2  UNION_VIEW;
  COUNT(*)
     45927
SQL>
SQL> create synonym my_view for UNIONALL_VIEW ;
Synonym created.
SQL> select count(*) from my_view;
  COUNT(*)
     46290
SQL> drop synonym my_view;
Synonym dropped.
SQL>
SQL> select object_name from user_objects where status = 'INVALID';
OBJECT_NAME
list shows other objects that we are not interested in
SQL>
SQL>  create synonym my_view for UNION_VIEW;
Synonym created.
SQL> select object_name from user_objects where status = 'INVALID';
OBJECT_NAME
list shows other objects that we are not interested in
SQL>
SQL> select count(*) from my_view;
  COUNT(*)
     45927
SQL>Hemant K Chitale

Similar Messages

  • Problem with Alter View

    Hello folk,
    It´s my first post here!
    I Hope that I can help us in question and ask!
    I have a dificult to alter table command.
    I think that I do nothing wrong, follow the command:
    ALTER VIEW desenv_pw.PRCR_MCVW903_CSP_DIM
    (CSP, DESCRIPTION)
    AS
    SELECT
    CARR_IDEN_CARRIER CSP,
         CASE
              WHEN CARR_DESC_CARRIER = 'Não identificado'
                   THEN 'Outros'
              ELSE CARR_DESC_CARRIER
         END DESCRIPTION
    FROM
    PWMART.BITB66_CARRIER_DIM
    WHERE
         BITB66_CARRIER_DIM.CARR_IDEN_CARRIER IN (0,25,99);
    Thanks for help me !
    Paulo Cauca

    Ok Thank´s for help SKU !
    I can´t use de command "Alter" to view in Oracle ?
    But with create or replace command worked well !!!
    Thank's again !!
    Paulo Cauca

  • How to wrap a view in oracle

    Does any one know how to wrap a view in Oracle, I know it is not possible, yet. Are there any third party software to wrap the logic in the view.
    Thanks,
    Sanjay

    Your best bet is to write a view that queries the source tables and contains any necessary business logic
    CREATE VIEW VBASE AS SELECT A.COLUMN_A FROM TABLE_1 A, TABLE_2 B, TABLE_3 C WHERE A.ID = B.ID AND B.ID = C.ID;
    create a view for exposure to the user that queries the base view.
    CREATE VIEW VSECURE AS SELECT COLUMN_B FROM VBASE;
    and grant privileges to VSECURE.
    GRANT SELECT ON VSECURE TO SECURE_USER;
    This will allow the user to see, query, and describe VSECURE without seeing the definition for VBASE.
    The advantage of the this approach is that the query engine can still push predicates down into the base view to optimize the performance or the query where as this is limited with the pipeline function and can become a tuning headache.
    eg.
    SQL> -----------------------------------------
    SQL> -- create some tables
    SQL> -----------------------------------------
    SQL> CREATE TABLE table_1(ID NUMBER, MESSAGE VARCHAR2(100))
    Table created.
    SQL> CREATE TABLE table_2(ID NUMBER, message2 VARCHAR2(100))
    Table created.
    SQL> CREATE TABLE table_3(ID NUMBER, message3 VARCHAR2(100))
    Table created.
    SQL> -----------------------------------------
    SQL> -- populate tables with some data
    SQL> -----------------------------------------
    SQL> INSERT INTO table_1
    SELECT ROWNUM,
    CASE
    WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'HELLO there joe'
    ELSE 'goodbye joe'
    END
    FROM DUAL
    CONNECT BY LEVEL < 1000000
    999999 rows created.
    SQL> INSERT INTO table_2
    SELECT ROWNUM,
    CASE
    WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'how are you joe'
    ELSE 'good to see you joe'
    END
    FROM DUAL
    CONNECT BY LEVEL < 1000000
    999999 rows created.
    SQL> INSERT INTO table_3
    SELECT ROWNUM,
    CASE
    WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'just some data'
    ELSE 'other stuff'
    END
    FROM DUAL
    CONNECT BY LEVEL < 1000000
    999999 rows created.
    SQL> -----------------------------------------
    SQL> --create base view
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE VIEW vbase AS
    SELECT a.MESSAGE,
    c.message3
    FROM table_1 a,
    table_2 b,
    table_3 c
    WHERE a.ID = b.ID
    AND b.ID = c.ID
    View created.
    SQL> -----------------------------------------
    SQL> --create secure view using base view
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE VIEW vsecure AS
    SELECT MESSAGE,
    message3
    FROM vbase
    View created.
    SQL> -----------------------------------------
    SQL> -- create row type for pipeline function
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE TYPE vbase_row
    AS OBJECT
    message varchar2(100),
    message3 varchar2(100)
    Type created.
    SQL> -----------------------------------------
    SQL> -- create table type for pipeline function
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE TYPE vbase_table
    AS TABLE OF vbase_row;
    Type created.
    SQL> -----------------------------------------
    SQL> -- create package
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE PACKAGE pkg_getdata AS
    FUNCTION f_get_vbase
    RETURN vbase_table PIPELINED;
    END;
    Package created.
    SQL> -----------------------------------------
    SQL> -- create package body with pipeline function using same query as vbase
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE PACKAGE BODY pkg_getdata AS
    FUNCTION f_get_vbase
    RETURN vbase_table PIPELINED IS
    CURSOR cur IS
    SELECT a.MESSAGE,
    c.message3
    FROM table_1 a,
    table_2 b,
    table_3 c
    WHERE a.ID = b.ID
    AND b.ID = c.ID;
    BEGIN
    FOR rec IN cur
    LOOP
    PIPE ROW ( vbase_row ( rec.MESSAGE, rec.message3 ) );
    END LOOP;
    END;
    END pkg_getdata;
    Package body created.
    SQL> -----------------------------------------
    SQL> -- create secure view using pipeline function
    SQL> -----------------------------------------
    SQL> CREATE or replace VIEW vsecure_with_pipe AS
    SELECT *
    FROM TABLE ( pkg_getdata.f_get_vbase ( ) )
    View created.
    SQL> -----------------------------------------
    SQL> -- this would grant select on the 2 views, one with nested view, one with nested pipeline function
    SQL> -----------------------------------------
    SQL> GRANT SELECT ON vsecure TO test_user
    Grant complete.
    SQL> GRANT SELECT ON vsecure_with_pipe TO test_user
    Grant complete.
    SQL> explain plan for
    SELECT *
    FROM vsecure
    WHERE MESSAGE LIKE 'HELLO%'
    Explain complete.
    SQL> SELECT *
    FROM TABLE ( DBMS_XPLAN.display ( ) )
    PLAN_TABLE_OUTPUT
    Plan hash value: 3905984671
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 16939 | 2365K| | 3098 (3)| 00:00:54 |
    |* 1 | HASH JOIN | | 16939 | 2365K| 2120K| 3098 (3)| 00:00:54 |
    |* 2 | HASH JOIN | | 24103 | 1835K| | 993 (5)| 00:00:18 |
    |* 3 | TABLE ACCESS FULL| TABLE_1 | 24102 | 1529K| | 426 (5)| 00:00:08 |
    | 4 | TABLE ACCESS FULL| TABLE_2 | 1175K| 14M| | 559 (3)| 00:00:10 |
    | 5 | TABLE ACCESS FULL | TABLE_3 | 826K| 51M| | 415 (3)| 00:00:08 |
    Predicate Information (identified by operation id):
    1 - access("B"."ID"="C"."ID")
    2 - access("A"."ID"="B"."ID")
    3 - filter("A"."MESSAGE" LIKE 'HELLO%')
    Note
    PLAN_TABLE_OUTPUT
    - dynamic sampling used for this statement
    23 rows selected.
    SQL> -----------------------------------------
    SQL> -- note that the explain plan shows the predicate pushed down into the base view.
    SQL> -----------------------------------------
    SQL> explain plan for
    SELECT count(*)
    FROM vsecure_with_pipe
    WHERE MESSAGE LIKE 'HELLO%'
    Explain complete.
    SQL> SELECT *
    FROM TABLE ( DBMS_XPLAN.display ( ) )
    PLAN_TABLE_OUTPUT
    Plan hash value: 19045890
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 2 | 15 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 2 | | |
    |* 2 | COLLECTION ITERATOR PICKLER FETCH| F_GET_VBASE | | | | |
    Predicate Information (identified by operation id):
    2 - filter(VALUE(KOKBF$) LIKE 'HELLO%')
    14 rows selected.
    SQL> -----------------------------------------
    SQL> -- note that the filter is applied on the results of the pipeline function
    SQL> -----------------------------------------
    SQL> set timing on
    SQL> SELECT count(*)
    FROM vsecure
    WHERE MESSAGE LIKE 'HELLO%'
    COUNT(*)
    19999
    1 row selected.
    Elapsed: 00:00:01.42
    SQL> SELECT count(*)
    FROM vsecure_with_pipe
    WHERE MESSAGE LIKE 'HELLO%'
    COUNT(*)
    19999
    1 row selected.
    Elapsed: 00:00:04.11
    SQL> -----------------------------------------
    SQL> -- note the difference in the execution times.
    SQL> -----------------------------------------

  • How to Register a View in Oracle Applications

    Hi,
    I have created a Custom View and want it to see it in one of the BPA Pages. For this purpose I shall need to register the view in Oracle Applications.
    Can you please provide me clues to do so. I tried the Application Developer responsibility, there I can only query the view and not register them.
    Also if I try using backend I could get hold of Package AD_DD which registers a table. Any clues for registering the View would be welcome.
    Thanks

    Thanks for your response.
    Actually I need to show Sales Order Line No, Federal Id and a few other Fields on our Invoice. Now these are not available in Oracle Recievables view. So I was trying to create my own View.
    I created a View in database. Now I am trying to create a Data source and associate this (custom created) View to it. However my View is not showing in the Views List of Values.
    I am not sure whether I am doing it right. Can you please help me with this. Any pointers to a document which explains my requirement would be great.
    Thanks
    Sumit

  • 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

  • Permissions required for an user to create a View in Oracle 10.2.0.1.0

    Hi,
    I am facing one serious issue with Oacle 10.2.0.1.0.
    I have an user (Atlas) created with below permissions.
    grant connect to atlas;
    grant resource to atlas;
    grant create public synonym to atlas;
    grant select any dictionary to atlas;
    grant query rewrite to atlas;
    I will create my database schema on this user Atlas. All my scripts are executing properly with Oracle 9i and 10g version 10.1.0.2.0. But when it comes to Oracle 10g version 10.2.0.1.0 the views creation is throwing an error saying that Insufficient Priviliges.
    I didn't get why this error is coming.
    What previliges does an user should require for creating a view in Oracle 10.2.0.1.0 version?
    I have installed Enterprise version of Oracle 10.2.0.1.0. Please suggest me with this.
    Thanks
    Rao

    CREATE VIEW was taken away from connect or resouce in 10.2.x. It has to be explicity granted... Not sure what this has to do with XML per-se :)

  • How to maintain Entries for VIEWS in ORacle Sql developer

    hi gurus,
    Could you please help in maintaining an entries for VIEW is Oracle SQL develope...I have created a VIEW by name SD_WH08....now i need to maintain some entries in this for my testing purpose...how do i do this?
    Your help is very much appreciated.
    Regards

    What do you mean by "maintaining an entries for VIEW" ?
    K.

  • How to Export Snapshots and Materlized View in Oracle 9i

    Hi,
    How to Export Snapshots and Materlized View in Oracle 9i .
    I require to Migrate from 9i to 10g with either Export or Script.
    Please help

    Using exp-imp for snapshots generally causes problems, at least for me. I would prefer taking their creation scripts and running them on the new database.
    By the way, what do you mean by "migrate from 9i to 10g"? Are you trying to create the same snapshots in another (10g) database or are you trying to upgrade your 9i database to 10g? If it is the latter then you can just upgrade the database automatically with the upgrade assistant or manually using upgrade scripts.

  • Oracle forms and reports with object views in oracle 9i

    Can We use oracle 9i Object Views in oracle forms and reports. If yes, then which version?

    MichaelFerrante,Thank you for your help.
    I have already used the HS services to connecto to external databases from our main Oracle database, and the solution works fine.
    But unfortunally for this particular client he cannont have installed a Oracle database due to internal policies restrictions.
    I can not migrate the full application to another technology like ADF in less than 6 or 8 months.
    Do you thifnk that there is any other solution?
    Mensagem editada por: user10660669

  • Discover Report  in Viewer through Oracle Apps

    hi,
    I want to launch the Discoverer Report in Viewer through Oracle Apps.
    Through Concurrent Program, by passing some parameters...?
    Do any one havei idea how to do it?
    Thanks in Advance
    regards
    -Seetha

    Hi,
    You can launch Disco Viewer or Plus from the Apps menu by creating an OracleOASIS Application Function.
    If you want to run Discoverer from a Concurrent Program then I assume you want the output of the Discoverer report as an HTML ( or some other format) available as output from the concurrent job. If that is the case then Discoverer Desktop Edition must be used to export the workbook into a file and this can be done from the current manager with a bit of development.
    On our system we have developed a concurrent request to schedule Discoverer workbooks. The main parameters for the concurrent request are the workbook you want to run, the parameters for the workbook, the responsibility you want to use to run the workbook in Discoverer and the type of export you want (ie. HTML, PDF, Excel etc). The concurrent request then sends the request to a Discoverer workstation. A simple VBSript on the workstation runs Discoverer from the command line and exports the workbook to a file to the request output directory back on the database server (using a SAMBA drive). The Discoverer report then can then viewed as output from the concurrent request. However, we mainly use a web page integrated to Apps to view and download output from our concurrent requests. This all works smoothly and provides a better alternative for Applications than using Discoverer scheduling.
    Hope that helps,
    Rod West

  • What is the use of materialised view in ORACLE

    Hi All,
    What is the use of Materialised view in ORACLE.Can anyone please help me out by giving a real time example in banking application (How MV is used in banking applications).
    Thanks & Regards,
    SB2013

    SB2013 wrote:
    What is the use of Materialised view in ORACLE.Can anyone please help me out by giving a real time example in banking application (How MV is used in banking applications).http://docs.oracle.com/cd/E11882_01/server.112/e25789/schemaob.htm#CNCPT411
    Just add for example in a banking application at the end of each paragraph
    E.g.
    >
    In data warehouses, you can use materialized views to compute and store data generated from aggregate functions such as sums and averages, for example in a banking application

  • New views in oracle 11.2

    Hello,
    I came across this link that lists all the new views that oracle introduced in 11.2 and indeed appear to be available, but many of the views doesn't contain/register any value. Does any one have any info on these views or how can one configure metric collection on these views?
    http://www.dba-oracle.com/t_11_2_new_v_dollar_views.htm
    v$goldengate_capture
    v$goldengate_message_tracking
    v$goldengate_transaction
    I am most interested in the v$goldengate_* views.
    Thanks,
    Arindam
    Edited by: AB007 on Feb 22, 2012 12:26 PM

    You might want to check the docs, perhaps ask Ben Prusinski directly, or check in the GG forum at GoldenGate
    The docs are at http://www.oracle.com/technetwork/middleware/goldengate/documentation/index.html
    The views are not documented in MOS either, so possibly not designated for public consumption yet, no matter what various authors have posted.

  • Developing database views between Oracle and SQL Server tables

    I am on Oracle 10.2, my organization has many SQL Server databases as well and has now made
    SQL server as company standard so many new databases will be developed in SQL Server. It is of course
    not possible to convert all Oracle databases to SQL Server, so a mix environment will exist. Two questions:
    1.     Is it possible to develop database views in Oracle (10g in my case) which join Oracle tables with tables in SQL Server 2008? If yes, how. I have seen some heterogeneous connectivity setup to connect SQL Server to Oracle, but not sure whether it is possible to develop a database view across two databases.
    2.     I know it is not a SQL Server forum, but many DBA’s know both Oracle and SQL Server. Is it possible to develop views in SQL Server (SQL Server 2008 R2 in my case) which join Oracle 10g and SQL Server 2008 tables? I know in SQL Server, there is way to set up linked servers, but do not know whether it is possible to develop views.
    Thanks a lot for your insight.

    You can create views that join local Oracle tables and remote SQL Server tables. I'm pretty sure you can do the reverse as well but I haven't personally done it.
    However, I would be very concerned about the performance you'd get if you created that sort of view. You'd very frequently end up in a situation where Oracle has to pull all the data in the remote table across the database link in order to apply predicates and join the data locally. That could be disastrous from a performance standpoint.
    Justin

  • Alter view

    hi
    how can we use alter view to update view by coding in vb.net    thanks

    "alter view to update view" could mean many things.  Here are a couple of interpretations:
    (1) Redefine a database view to retrieve different data.
    Don't. 
    Unless you're writing an application that will maintain database structures, this isn't something you should be doing from application code.  Indeed, the account used by your application should not have any database permissions to do this.  Work
    with tables, views, etc., but don't change them. 
    (2) Change the permissions on a View so that you can perform Updates through it.
    Don't. 
    See (1).
    Also, some views retrieve data from many tables, making it impossible use them in this way.  
    Regards, Phill W.

  • Views in oracle

    what is composite view in oracle ?
    what is the difference between composite & materialized view ?

    Hi
    There is no composite view in the Oracle. This is 100% correct. We have composite primary key, composite index are there. Means more than one column of primary key called composite PK, same more than one column index called composite index.
    complex view
    Complex view is a database object which is created by more than one table and with group by functions.(max, min, count,avg,sum). So, we can't perform DML operations on this view. Only Instead of trigger can help you.
    Ganesh has given the Example of complex view. That is more than enough. Regarding Materialized view, given the URL is enough.Still you have any queries...!!! shoot them.
    Regards
    KPR.
    *If this response correct then mark it as correct answer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • How do you both move from iPhoto and get masters on an external drive?

    My partner currently has her photo library part in iPhoto and part in folders on her desktop (not imported or referenced by iPhoto).  She has a MacBook Pro.  She now wants to buy Aperture and we want to put all the Masters on a connected hard drive a

  • Formatted search authorization

    hi. i have created a normal user ap. ap has full authorization for "define formatted search". when ap logs in and tries to do formatted search on the warehouse feild in A/R Invoice, the message is that he is not permitted to perform the action. what

  • Running iTunes on my computer with my iTouch

    So I've got a computer hooked up to my stereo and the iTunes files there are full lossless so I'd like to listen to that rather then the compressed sounds that are on my iTouch when I'm home. And I'd like to control it from the iTouch since the compu

  • How to view pricing conditions in a scheduling agreement?

    Dear Friends Will you please tell me how to see pricing condition and tax conditions in a scheduling agreement? Thanks Chandra

  • Lost over 2,000 songs.

    I have boughten over 2,000 songs, but when I went to download them there was zero songs in my purchased... Someone please help me!!!!!!!!!!!!! How do i get my songs back???