How to rename tables and refresh views

Hi all
I need to write a script that will rename several tables and at the same time I would like to refresh all the views that point to this table.
questions:
- how do I rename a table
- how do I refresh the views that point to this table?
Thanks
J

Hello,
You might have to write pl/sql to recreate all views depends upon the tables you just renamed. You can use user_dependencies to identify the views and create sql to use new_table_name
DECLARE
   CURSOR mcur
   IS
      SELECT table_name
      FROM user_tables
      WHERE table_name IN ('A1');
   v_sql   VARCHAR2 (100);
BEGIN
   FOR cur IN mcur
   LOOP
      v_sql   :=
         'RENAME ' || cur.table_name || ' to ' || cur.table_name || '_NEW';
      DBMS_OUTPUT.put_line (v_sql);
      EXECUTE IMMEDIATE v_sql;
   END LOOP;
END;Regards

Similar Messages

  • How to find schema of a table and a view

    Hi,
    I have an old form which uses one table and one view. I know its database. Now I'm making another form in some other database and want to use the old form but for that I need to know the schema of that table and the view so that I can give the schema name and db link to connect (meaning schema.table_name@dbname). How do I find out the schema for that table and view.
    I did a search by using "select owner from all_objects where object_name = tablen" and it says PUBLIC. There's no schema called Public. I can see Public Synonyms but cannot find that table and view in it. So please help. I'm trying since long to find its schema.
    Thanks.

    Hi ,
    Isn't it peculiar that i have declared a public synonym on table BIOGR as user523269 does.... and the sql statement:
    select owner from all_objects where object_name='BIOGR' works.... whereas of user523269 does not...?????
    SQL> select * from dba_synonyms where table_name='BIOGR';
    OWNER                          SYNONYM_NAME                   TABLE_OWNER                    TABLE_NAME                     DB_LINK
    PUBLIC                         BIOGR                          HIS                            BIOGR Regards,
    Simon

  • 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>

  • How to create tables and relationship between ?

    Hello everybody,<o:p></o:p>
    I have three table with structures as follow:<o:p></o:p>
    <o:p> </o:p>
    Table1
    contains information on ledger accounts,and
    Table2 contains Groups of the detailed
    accounts.
    When defining ledger
    accounts , we must associated them with
    groups of detailed accountsthat
    are
    set
    by the
    Check
    boxes. groups of detailed accounts are three
    levels, At each level, there are fifteen
    groups as follow:
    1_others ,2_People ,3_companies ,4_
    Cost centers ,5_projects ,6_
    Letter of Credits ,7_ Current
    Accounts ,8_
    Banking facilities ,9_
    Commodity ,10_ Branches
    aggregation ,11_ Purchase
    Contract
    Services ,12_
    Sales Contract
    Services ,13_
    Export Products ,14_
    Control account ,15_
    Months.Table3 contains detailed accounts information that should associated with groups of detailed accounts(fifiteen groups).
    In addition, we
    have in our program four combobox,
    detailed accounts must be
    linked to the detailed groups
    so that, by selecting one ledger account in combobox1 it should display detailed accounts of level1 in combobox2 ,detailed accounts of level2
    in combobox3 and detailed accounts of level3 in combobox4.<o:p></o:p>
    <o:p> </o:p>
    How
    to design tables and the relationships between them, so
    with select the ledger account I can see the detailed
    accounts of per level in other comboboxes?<o:p></o:p>
    <o:p> </o:p>
    I've
    spent
    a lot of time
    on this
    subject
    but
    I have
    not been able
    to
    solve this problem.<o:p></o:p>
    Please help me,<o:p></o:p>
    Best regards.<o:p></o:p>

    I am guessing....I hope it is helpful...
    >1_others ,2_People ,3_companies ,4_
    Cost centers ,5_projects ,6_
    Letter of Credits ,7_ Current
    Accounts ,8_
    Banking facilities ,9_
    Commodity ,10_ Branches
    aggregation ,11_ Purchase
    Contract
    Services ,12_
    Sales Contract
    Services ,13_
    Export Products ,14_
    Control account ,15_
    Months.
    Setup a table for each.
    >Table3 contains detailed accounts information that should associated with groups of detailed accounts(fifiteen groups).
    Setup the AccountDetail(1,2,3 level) tables with 15 NULLABLE FOREIGN KEYs. If some group is not applicable for an FK, keep the value NULL, otherwise enter a valid PK value.
    >Table1
    contains information on ledger
    accounts,and Table2 contains
    Groupsof the detailed
    accounts
    Setup LedgerAccount tables.
    Setup LedgerDetailXref table with FOREIGN KEYS to LedgerAccount & AccountDetail(1,2,3) tables.
    FOREIGN KEY examples: http://www.sqlusa.com/bestpractices2005/bankdatabase/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • 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 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!

  • Query Dictionary tables and V$ views in EM

    Hello;
    I want to query dba_ tables and v$ views from Enterprise manager (10g).
    I hv tried that in the Tables -> SYS schema ; But these tables are not shown there. Im unable to query from the EM.
    Able to query from the sql plus , Where i have logged as SYS
    select status from v$instance;
    From where can i access these tables; (in EM)
    v$instance
    v$database
    dba_tablespaces
    Edited by: Zerandib on Dec 8, 2009 8:39 AM

    Zerandib wrote:
    From where can i access these tables; (in EM)
    v$instance
    v$database
    dba_tablespaces
    Those are not tables, they are views. Try looking under Adminstration|Schema|Views with schema as SYS. Keep in mind many of the V$ names, such as V$INSTANCE, are public synonyms for V_$ views. For example V$INSTANCE is a public synonym for V_$INSTANCE.

  • How to drow Table and templetes in dotted line

    Hi,
    how to drow Table and templetes in dotted line  ?
    Regards
    Bikas

    Hi,
    Setting is saved and working fine but that setting is for form painter and table painter
    I need dotted line in the printout, Please understand the question clearly.
    Is it possible to get dotted line in the printout ?
    has anyone done this ? please help.
    Regards
    Bikas

  • View on "Transparent Table and DataBase View" ????

    Hi
    I have three transparent tables and four database views in R/3.
    Is it possible to create the view on "Transparent Table and DataBase View". Please let me know
    kumar

    no it's not possible.

  • How to rename Photos and Videos ???????

    Could somebody please tell me how to rename Photos and Videos on Iphone5 ?
    If you cannot, what is the logical explanation behind it ?
    Would of thought this is something basic....

    Since photos and videos should always be synced to a computer for storage, rename them there.  I'm assuming you're trying to find a way to rename in the Photo app, right?  Don't trust your phone or even icloud to safely store your photos.  Think of the iphone as a digital camera.  Most digital cameras don't let you rename a photo.

  • How to search tables and views used in the code of oracle fmb 6i from another form???

    Hii guys, this is a very interesting question and i hope that it will have ample amount of answers.
    My requirement is to know the number of tables and views and backend functions/procedures which are used in the code written in the oracle forms 6i,
    all i want is to display whole views, tables or functions/procedures which are written  in the code of a particular fmb, i do have the path of that fmb and i want to read the code and search through it's entire code for the tables/views/backend procedures/functions written in the code. So how to search through the entire code of a particular form (6i) and make it display through another form.
    I am using oracle forms 6i.
    Please help me out....
    With Regards:
    Ankit Chandra

    Here is a modified dealForm.jsp that merges the 2 steps - both symbol submission and Yahoo convert is done by it. Play with it and add your DB code to it:
    <html>
    <head><title>IPIB Database Selection</title></head>
    <body bgcolor="#DFDFFF">
    <H1><CENTER>IPIB Database Selection</CENTER></H1>
    <font size=4>
    <%@ page language="java" %>
    <%@ page import="java.net.*,java.io.*,java.util.*" %>
    <%
    String symbol = request.getParameter("symbol");
    if (symbol != null) {
    String urlString = "http://finance.yahoo.com/download/javasoft.beans?SYMBOLS=" + symbol + "&format=ab";
    try {
    URL url = new URL(urlString);
    URLConnection con = url.openConnection();
    InputStream is = con.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line = br.readLine();
    StringTokenizer tokenizer = new StringTokenizer(line,",");
    String name = tokenizer.nextToken();
    name = name.substring(1, name.length()-2);
    String price = tokenizer.nextToken();
    price = price.substring(1, price.length()-2);
    %>
    <p>
    Original line from yahoo <%= line %>
    </p> <p>
    Name: <%= name %>
    </p> <p>
    Price: <%= price %>
    </p> <p>
    Pub DB processing code from dealLoad.jsp here
    </p>
    <%
    } catch (IOException exception) {
    System.err.println("IOException: " + exception);
    } else { %>
    <form action="dealForm.jsp"method="GET">
    <p>Enter Symbol: <input size="20" name="symbol">
    <inputtype="submit" value="Submit">
    </p></form>
    <% } %>
    </font>
    </body>
    </html>

  • 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.

  • How to read tables and fields transaction,how to find table from a strucre

    hi all,
      i am having problem in reading tables and fields for developing a customised report. can anybady help me how to extract tabele and fields from a transaction code and how to map table from a structure.
    It will me much help full, if u had any documentation. u should be appreciated.
    Thanking u
    kiran
    Message was edited by:
            kiran

    Hi Kiran,
    You can make use of the tables or Views available.
    Reward If Useful.
    Regards,
    Chitra

  • Select data from a table and a view: field with same content and different type

    hi all,
    I need data from a table hrp1001 and a view V_USR_NAME. What they have in common are the content of the fields SOBID and BNAME .
    It will be easier if those fields add a same type but they dont.
    Any suggestions for a workaround?
    Thanks

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • How to create table and digital signature ?

    Hello,
    I would like to ask two questions regarding SAP interactive forms by adobe.
    1st question:
    How to create table in interactive form?
    Table that i can add rows and column and will show it in the form.
    Example the rows and columns that i want:
    <u><b>ID:</b></u>                <b><u>Name:  </u>  </b>               <u><b>DOB:</b></u>
    1                  Jack                      01/02/80
    2                  Ivy                         10/12/82
    2nd question:
    How to create digital signature ?
    I'm creating a adobe forms which need employee to sign on the form. I use signature field at my form. However, i don't know how to create a new signature and insert in the signature field.
    Can any one provide the answer with step by step guide?
    Thanks a lot

    Hi Pradeepa,
    you said you have your digital signature in
    BMP format? That means Bitmap and would mean you are actually talking about a picture! THIS IS NOT A DIGITAL SIGNATURE!
    A digital signature is a cryptographic key (aka public key cryptography) that is used to digitally sign a document, or at least a hash value derived from the document. Digitally signing means, applying the key in a well defined way (this is the algorithm used) to the document or hash value. You do this with your private key and the receiver of the document can then use your public key (which you can distribute in any way you want, even unsecure) to unencrypt the hash value. If this succeeds the receiver knows that the document was signed by you.
    This is because both keys are mathematically related in such a way, that what one key encrypted can only be decrypted by the corresponding other key and by no other key. You even can´t decrypt a document with the same key it was encrypted with, this is the difference to symmetric encryption - please have a look at help.sap.com and search for digital signatures.
    The named formats (afs, pfx and p12) are ways of coding the key, together with information about your person, such as email address and information about validity of the key into a
    certificate. This type of certificate is then called a x.509 certificate and is the same you might have seen when connecting to a secure webserver such as the one of your bank website. 
    Signing a form with such a certificate provides for mathematically and therefore business related proove of a users identity.
    In case you are really using a bitmap, this cannot work and would not serve you any good.
    Ask yourself this question: I want to make sure that the form was signed by a specific person. How can I make sure that the signing can only be done by the person pretending to have done so?
    A bitmap contains a picture, probably of the persons handwritten signature. How can I make sure that this picture was NOT recreated in MS Paint or Photoshop by someone else?
    The answer is:
    you can't! Therefore this way of prooving identity is useless. 
    You need to provide your users with digital signatures, put these in the certificate cache of your IE.  If a user then clicks on the signing field, the private key is used to digitally sign the form - create a hash value of the form and encrypt it with the private key. After the form is send back to the server or you, you use the corresponding public key to decrypt the hash value and, as said above, if this succeeds, identity of the signer is proven.
    THIS IS AN OVERSIMPLIFICATION! You might want to take a look at Adobe Reader Credentials.
    Regards,
       Christian

Maybe you are looking for