Creating multiple tables based on existing tables

Hi,
I have to create 60 tables based on existing 60 tables. Instead of creating one by one how can I create all 60 at once.
The current 60 tables are named FY11_ACC1, FY11_ACC2, FY11_SALES1, FY11_SALES2 ...... , but all 60 tables start with FY11. I need to create the same structured tables but with FY12 names like FY12_ACC1, FY12_ACC2, FY12_SALES1, FY12_SALES2 .....
Currently I am using "create table FY12_ACC1 as select * from FY11_ACC1 where 1=0". Is there a way I can write all of them in one query?
Thanks for your time and help.

ssk1974 wrote:
Hi,
I have to create 60 tables based on existing 60 tables. Instead of creating one by one how can I create all 60 at once.
The current 60 tables are named FY11_ACC1, FY11_ACC2, FY11_SALES1, FY11_SALES2 ...... , but all 60 tables start with FY11. I need to create the same structured tables but with FY12 names like FY12_ACC1, FY12_ACC2, FY12_SALES1, FY12_SALES2 .....
Currently I am using "create table FY12_ACC1 as select * from FY11_ACC1 where 1=0". Is there a way I can write all of them in one query?
Thanks for your time and help.Well, i'm assuming FY = Fiscal Year and 11 = 2011 and then ACC1 = Account #1.
From the sounds of things, your design isn't likely "correct'.
If you'd care to delve in to the requirements a little bit ... what you have and what you need (business speak wise) there are no shortage of experts here that i'm sure would be happy to help you.
If you're stuck with what you've got (or don't care to change your 'design') and all you care about is achieving that please disregard this message.

Similar Messages

  • Add column to user defined type based on existing table

    Hello guys,
    I am trying to compile my function which returns a user defined type based on existing table. Throughout the initializing process though my query returns one additional column - SCORE(1). Here is my package:
    create or replace
    PACKAGE STAFF_AGENCY_PKG AS
    TYPE TYPE_SEEKER_TABLE IS TABLE OF TOSS.SEEKER%ROWTYPE;
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED;
    END STAFF_AGENCY_PKG;
    create or replace
    PACKAGE BODY STAFF_AGENCY_PKG
    AS
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED
    IS
    R_TBL TYPE_SEEKER_TABLE; -- to be returned
    BEGIN
    FOR R IN(
    SELECT Seeker.SEEKER_ID,
    Seeker.FIRSTNAME,
    Seeker.LASTNAME,
    Seeker.NATIONALITY,
    Seeker.ISELIGIBLE,
    Seeker.BIRTHDATE,
    Seeker.ISRECIEVEEMAILS,
    Seeker.HIGHESTDEGREE,
    Seeker.ETHNICITY,
    Seeker.GENDER,
    Seeker.ISDISABILITY,
    Seeker.DISABILITY,
    Seeker.CV,
    Seeker.PASSWORD,
    Seeker.PREFFERED_CITY,
    SEEKER.EMAIL,
    SEEKER.JOB_PREFERENCES_ID,
    SCORE(1)
    FROM SEEKER Seeker
    WHERE CONTAINS(CV, '<query>
    <textquery lang="ENGLISH" grammar="context">' ||
    GET_RELATED_CATEGORIES(IN_KEYWORD) ||
    '</textquery>
    <score datatype="INTEGER"/>
    </query>', 1) > 0
    LOOP
    PIPE ROW(R); --Error(38,10): PLS-00382: expression is of wrong type
    END LOOP;
    RETURN;
    END GET_SEEKERS;
    END STAFF_AGENCY_PKG;
    How do I need to amend my user type in order to suffice?
    Oracle Release 11.2.0.1.0
    Many thanks in advance!

    >
    How do I need to amend my user type in order to suffice?
    >
    You will need to create two new TYPEs. One that has all of the columns of the TOSS.SEEKER table and the new SCORE column and then a TYPE that is a table of the first type.
    See the Example 12-22 Using a Pipelined Table Function For a Transformation in the PL/SQl language reference
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm#i53120
    Here is the first part
    -- Define the ref cursor types and function
    CREATE OR REPLACE PACKAGE refcur_pkg IS
      TYPE refcur_t IS REF CURSOR RETURN employees%ROWTYPE;
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;
    FUNCTION f_trans(p refcur_t)
          RETURN outrecset PIPELINED;
    END refcur_pkg;
    CREATE OR REPLACE PACKAGE BODY refcur_pkg IS
      FUNCTION f_trans(p refcur_t)
       RETURN outrecset PIPELINED IS
        out_rec outrec_typ;
        in_rec  p%ROWTYPE;
      BEGINModify
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;to include all of the columns you need. Unfortunately you will have to manually list all of the columns of the TOSS.SEEKER table. If you expect to need this same structure in other places you should create them as SQL types instead of PL/SQL types.
    This example should be enough to show you how to change your code to do something similar.

  • Why do we create multiple aliases to a single table?

    <h4>{color:#0000ff}Hi,{color}</h4>
    <h4></h4>
    <h4></h4>
    <h4>{color:#0000ff} Why do we create multiple aliases to a single table in the same query?{color}</h4>
    <h4></h4>
    <h4></h4>
    <h4>{color:#0000ff}{color:#000000}For Ex: {color}{color}</h4>
    <h4>
    {color:#000000}select name,address,phone, from emp e, emp e1{color}</h4>
    <h4></h4>
    <h4>{color:#000000}where e.empid = e1.empid;{color}</h4>
    <h4>
    {color:#0000ff}ofcourse the above query's where condition is not correct, but i am giving as an example only{color}</h4>
    <h4>{color:#0000ff}I have seen similar kind of queries where a single table name is aliased 10 times in the same query{color}</h4>
    <h4>{color:#0000ff}can someone help me to understand the logic behind it?{color}</h4>
    <h4>{color:#0000ff}Thanks in advance{color}</h4>
    <h4>{color:#0000ff}greddy.{color}</h4>
    Edited by: greddy on Oct 24, 2008 2:46 AM

    Hi,
    When you say
    FROM    emp  e
    ,       emp  e1you are using two copies of the same table.
    Can you imagine using two copies of the same book at the same time?
    Say you see a word (like "hyrax") that you don't know. You might look up that word in the dictionary.
    The English sentence "Open the dictionary to the page containing the new word." is like this SQL query:
    FROM    dictionary
    WHERE   :unknown_word  BETWEEN low_guide_word and high_guide_wordWhat if you saw that word while reading a book (let's call it book_a).
    You might want to leave book_a open, and place the dictionary beside book_a, so you can easily compare how the word is used in book_a with the definition in the dictionary.
    This corresponds to joining two tables in SQL:
    FROM    book_a     
    JOIN    dictionary  ON unknown_word BETWEEN low_guide_word AND high_guide_word
    WHERE   book_a.page  = whatever  -- NOTE: both tables have a column called pageor you can use aliases for one or both of the tables
    FROM    book_a      a
    JOIN    dictionary  d  ON a.unknown_word BETWEEN d.low_guide_word AND d.high_guide_word
    WHERE   a.page  = whatever  -- NOTE: both tables have a column called pageNow, imagine that book_a is itself the dictionary. Say you saw the word "hyrax" while you were looking up another word, "ibex".
    You can do a side-by-side comparison, as above, if you have two copies of the dictionary. Leave one copy open to "ibex", and open the other copy to "hyrax".
    This corresponds to a self-join in SQL:
    FROM    dictionary  a
    JOIN    dictionary  d  ON a.unknown_word BETWEEN d.low_guide_word AND d.high_guide_word
    WHERE   a.page  = whatever  -- NOTE: both tables have a column called pageNotice that this last bit of code is identical to the previous one, except that book_a is replaced with dictionary.
    In this case, you must you a table alias, at least for one copy. It wouldn't make any sense to say "Leave the dictionary open to "ibex" and open the dictionary to "hyrax". You have to have some unique way of referring to each copy, such as "Leave the dictionary on my left open to "ibex" and open the dictionary on my right to "hyrax"."

  • How to create a table from an existing table with new column

    Hi !
    Please help me.
    I want to create a table from an existing table with data and add two new column to the new table.
    What will be the syntax?

    craete table new_table as select a.*, 'somevalue' new_col1, 'somevalue'
    new_col2 from old_table a;Also there is a pitfall - newly created table will accept column type and precision from the select statement, so further you can be needed to modify columns
    if you want to have VARCHAR2 instead of CHAR for example:
    SQL> create table new_dept as select dept.*, 'New data' new_col from dept;
    Table created.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            CHAR(8)
    SQL> alter table new_dept modify (new_col varchar2(8));
    Table altered.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            VARCHAR2(8)Rgds.
    Didn't see michael's post - it reflects the fix for this problem using CAST.
    Message was edited by:
    dnikiforov

  • Best way to create a table based on another table

    Hello,
    I am trying to create a table based on another table with all the data in it. It has large data.
    create table <tablename> as select * from table1.
    Is this the best way of doing it or is there any other way. please advice.
    thanks

    I am suggested to create new table as
    create table <newtable> as
    select * from <oldtable> where rownum < 1;
    then
    alter table <newtable> compress;
    then
    insert /*+ append */ into <newtable> as select * from <oldtable>;
    but i getting an error saying missing values key words ora- 00926.
    please advice

  • How to update one table based on another table ??

    Hello Friends:
    I am trying to run the following query in oracle but it won't run.
    UPDATE BOYS
    SET
    BOYS.AGE = GIRLS.AGE
    FROM GIRLS
    WHERE
    BOYS.FIRSTNAME = GIRLS.FIRSTNAME AND
    BOYS.LASTNAME = GIRLS.LASTNAME;
    This query runs fine in sql server but in oracle its saying can't find "SET". PLease tell me what is the correct syntax in oracle to update one table based on another table.
    thanks

    See if this helps.
    If you wrote an SQL statement:
    update boys set age = 10;
    Every row in the boys table will get updated with an age of 10. But if you wrote:
    update boys set age = 10
    where firstname = 'Joe';
    Then only the rows where the firstname is Joe would be updated with an age of 10.
    Now replace the 10 in the above statements with (select g.age from girls g where g.firstname = b.firstname and g.lastname = b.lastname) and replace where firstname = 'Joe' in the second statement with where exists (select null from girls g where g.firstname = b.firstname and g.lastname = b.lastname). The same concepts apply whether 10 is an actual value or a query and whether you have a where clause with the update statement to limit rows being updated.
    About the select null question regarding the outer where clause:
    Since the query is checking to see if the row in the girls table exists in the boys table what the column is in this select statement doesn't matter, this column isn't being used anywhere. In this case Todd chose to use null. He could have also used a column name from the table or a lot of times you'll see the literal value 1 used here.

  • How to create multiple rows in a child table from the multi select Lov

    Hi
    We have Departments and EmployDept and Persons tables and each employee can associate multiple departments and vice versa.While creating a Department page there should be a Multi Select LOV(values from Persons table) with search option for the Persons.From the search panel we can select multiple persons for that department.Suppose we have selected 5 persons and click on submit, then it should create 5 rows in the EmployDept table for 5 persons with that department id.
    Any inputs on how to implement this scenario please..

    Maybe you can get some ideas from here -
    http://adfdeveloper.blogspot.com/2011/07/simple-implementation-of-af.html

  • Create new table based on old table

    Hello All,
    I have a JTable. The user can re-arrange columns in this table. Then the user can select a couple rows and create a new selection set table based on these rows. The problem is as follows: When the user re-arranges the columns, I cannot seem to retrieve the new order.
    Ex)
    A table is created with fields: A B C
    User rearranges to: B A C
    I call code and fields are returned as: A B C
    for(int i=0; i<((DefaultTableModel)super.getModel()).getColumnCount(); i++) {
      String name = ((DefaultTableModel)super.getModel()).getColumnName(i);
      System.out.println("Name: " + name);
    }Thanks for any/all help!

    Nevermind, got it to work by the below code. Still don't understand why the above code didn't work though.
    Enumeration e = super.getTableHeader().getColumnModel().getColumns();
    while(e.hasMoreElements()) {
      String name = (String)((TableColumn)e.nextElement()).getHeaderValue();
      System.out.println("Name: " + name);
    }

  • How to create multiple new rows in ADF Table?

    Hello,
    being new to ADF Faces/BC I managed to display data in an ADF Table and create new entries using the "CreateInsert" operation (one at a time).
    Now, the next task is to create multiple new rows at the same time, set some default values and display the new rows in the ADF table. Then the user will enter additional data and commit the new rows.
    Where do I step in? In the EntitiyImpl? Can this be handled declaratively or do I have to implement custom method(s) in the AM?
    Thanks
    Gerald

    Hi John,
    I'm still getting the following error
    Error(94,144): method getValue() not found in class javax.faces.el.ValueBinding
    What should it be casted to?
    The code in backing bean is like this..
    package view.backing;
    //import com.test.model.TestAppModuleImpl;
    import javax.faces.component.html.HtmlForm;
    import javax.faces.component.html.HtmlPanelGroup;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    //import javax.faces.event.FacesListener;
    //import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.faces.component.core.data.CoreColumn;
    import oracle.adf.view.faces.component.core.data.CoreTable;
    import oracle.adf.view.faces.component.core.input.CoreInputText;
    import oracle.adf.view.faces.component.core.nav.CoreCommandButton;
    import oracle.adf.view.faces.component.core.output.CoreMessages;
    import oracle.adf.view.faces.component.html.HtmlBody;
    import oracle.adf.view.faces.component.html.HtmlHead;
    import oracle.adf.view.faces.component.html.HtmlHtml;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.Row;
    import oracle.jbo.ViewObject;
    //import oracle.jbo.server.ViewObjectImpl;
    //import view.utils.EL;
    public class MultipleInsert1 {
    private HtmlHtml html1;
    private HtmlHead head1;
    private HtmlBody body1;
    private CoreMessages messages1;
    private HtmlForm form1;
    private CoreTable table1;
    private CoreColumn column1;
    private CoreInputText inputText1;
    private CoreColumn column2;
    private CoreInputText inputText2;
    private CoreCommandButton commandButton1;
    private HtmlPanelGroup panelGroup1;
    private CoreCommandButton commandButton2;
    public void setHtml1(HtmlHtml html1) {
    this.html1 = html1;
    public void createMultiRows(ActionEvent actionEvent) {
    DCBindingContainer dc = (DCBindingContainer) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings}").getValue();
    DCIteratorBinding iter = dc.findIteratorBinding("TestView1Iterator");
    ViewObject vo = iter.getViewObject();
    for (int i=1; i<=5; i++) {
    Row newRow = vo.createRow();
    newRow.setAttribute("Id", i);
    ApplicationModule am = vo.getApplicationModule();
    am.getTransaction().commit();
    vo.executeQuery();
    Do I need to import something else?
    Thanks,
    Shri.

  • Create a relationship between two existing tables

    When I create a new table the wizard exposes the ability to add a foreign key column. However when editing an existing table the only option I seem to have is to create a lookup table, which is a new table that is autogenerated. I find it hard to believe that it's impossible to create and manage relationships in APEX...but I've unable to find the access point if there is one.

    Hello,
    I'm not sure what version of APEX you are using as you don't say, but in my 2.2.0.00.32 installation, when I select a table using the Object Browser, select Constraints from the choices running along the top of the page, then click the Create button/link, the Foreign Key option is available in the Constraint Type drop-down list.
    Hope that helps a bit,
    Mark

  • Create multiple capture processes for same table depending on column value

    Hi,
    is it possible to create multiple realtime downstream capture processes to capture changes for the same table depending on column value?
    Prakash

    i found it - by using subset rules
    prakash

  • Suggestions for table partition for existing tables.

    I have a table as below. This table contains huge data. This table has so many child tables .I am planning to do a 'Reference Partitioning' for the same.
    create table PROMOTION_DTL
      PROMO_ID              NUMBER(10) not null,
      EVENT                 VARCHAR2(6),
      PROMO_START_DATE      TIMESTAMP(6),
      PROMO_END_DATE        TIMESTAMP(6),
      PROMO_COST_START_DATE TIMESTAMP(6),
      EVENT_CUT_OFF_DATE    TIMESTAMP(6),
      REMARKS               VARCHAR2(75),
      CREATE_BY             VARCHAR2(50),
      CREATE_DATE           TIMESTAMP(6),
      UPDATE_BY             VARCHAR2(50),
      UPDATE_DATE           TIMESTAMP(6)
    alter table PROMOTION_DTL
      add constraint PROMOTION_DTL_PK primary key (PROMO_ID);
    alter table PROMOTION_DTL
      add constraint PROMO_EVENT_FK foreign key (EVENT)
      references SP_PROMO_EVENT_MST (EVENT);
    -- Create/Recreate indexes
    create index PROMOTION_IDX1 on PROMOTION_DTL (PROMO_ID, EVENT)
    create unique index PROMOTION_PK on PROMOTION_DTL (PROMO_ID)
    -- Grant/Revoke object privileges
    grant select, insert, update, delete on PROMOTION_DTL to SCHEMA_RW_ROLE;I would like to partition this table .Most of the queries contains the following conditions.
    promo_end_date >=   SYSDATE
    and
    (event = :input_event OR
    (:input_Start_Date <= promo_end_date           
    AND promo_start_date <= :input_End_Date))Any time the promotion can be closed by updating the PROMO_END_DATE.
    Interval partioning on PROMO_END_DATE is not possible as PROMO_END_DATE is a nullable and updatable field.
    I am now to table partition.
    Any suggestions are welcome...

    DO NOT POST THE SAME QUESTION IN MULTIPLE FORUMS PLEASE!
    Suggestions for table partition of existing tables

  • CM25: Sort standard table based on custom table.

    Hi Experts,
    I need to sort the CM25 capacity table based on a ZTABLE where we will define the sequence number of each material. So when CM25 is executed the material should get sorted based on sequence number maintained in Ztable. Now the challenge is how to achieve this sorting before we display the capacity table.
    anybody has faced such scenerio please help us.
    There are few user exits available but not able to find out how to achieve the required functionality.
    Regards,
    Raghav
    Edited by: Julius Bussche on Jul 30, 2009 9:29 AM
    In future threads with meaningless subject titles will simply be deleted as you appear to be doing this intentionally

    First, let me say that I have no experience with this CM25 table and where/how it is used or displayed, but here's how I look at it:
    But what is the real problem?
    1. Don't know the user exit / BAdI to be used?
    2. Don't know how to do the sorting?
    3. .....?
    Answer:
    1. This will be a matter of trying I would say and reading the documentation of the exit/BAdI.
    2. You can do dynamic sorting of an internal table (if it is an internal table that is used before displaying it).
    DATA: lv_sort1 TYPE CHAR10 VALUE 'NAME_OF_COLUMN_FROM_ZTABLE',
               lv_sort2 TYPE CHAR10 VALUE 'NAME_OF_OTHER_COLUMN_FROM_ZTABLE'.
    SORT itab BY (lv_sort1) ASCENDING (lv_sort2) DESCENDING.
    Edited by: Micky Oestreich on Jul 30, 2009 7:34 AM

  • How to create multiple idocs based on complex condition

    HI Users,
    my scenario is jms(xml file) to idoc. for each file have multiple records for each record i need to create multiple idocs.
    source structure:
    <lineitem>
    <student sid="cid">456</student>
    <hreference>
    <reference rtype="number">123</reference>
    </hreference>
    <hreference>
    <reference rtype="number">789</reference>
    </hreference>
    <hreference>
    <reference rtype="char">147</reference>
    </hreference>
    now condition is One input message must create only one output message for each unique  rtype="number" and sid="cid" combination.
    for example
    1. rtype="number" and sid="cid" the value combination means 123456 for this one idoc
    2.  rtype="number" and sid="cid" the value combination means 789456 for this one idoc
    --> the below file shows with out sid="cid"
    <lineitem>
    <student sid="abc">456</student>
    <hreference>
    <reference rtype="number">123</reference>
    </hreference>
    <hreference>
    <reference rtype="number">789</reference>
    </hreference>
    <hreference>
    <reference rtype="number">147</reference>
    </hreference>
    in this case we have to consider only rtype="number" so here we need to create  3 idocs.
    Could anyone help me in this regard.
    Thanks in advance

    Hi Swathip,
    Change the occurence of the IDoc to "unbounded", so that multiple IDocs can get create
    Try with below logic
    If (SID = "CID")
    Then
         If(rtype = "number")
              concat(student,reference ) ---> removeContext ---> Idoc          
    Else
         rtype ---> removeContext ---> Idoc
    If combination of unique  student and reference can occur more than once in the XML, use sort command and splitByValue (Value Change)
    Edited by: chandra shekhar on Jul 3, 2011 12:53 PM

  • How to create one to many relation database based on existing Tables?

    Let say I have got 10 tables. Out of these 10 tables one table is used to navigate to other tables and at the some time providing some useful information. Therefore other 9 Tables have the identical structure.
    The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?

    Hello,
    >>The question is, how can I convert these 10 tables into 2 tables, ie each row of first table correspond to the different data of the other table (one to many relation)?
    I do not quite understand what you ask and I doubt if Entity Framework supports this scenario, since you mentions these tables already exist, after importing them to the designed windows, we cannot modify them or it would throw an error shows the database
    and model is mismatched.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • RFC to SMS using XI

    Hello Experts, I need to implement the scenario RFC ->XI->SMS. I have already implemented the RFC to Email using XI, and all the mails that are sent are forwared to my telephone number by the Telephone Service. All the mails that i recieve are in htm

  • My N8 is dead. 'What would you do with it ?'

    Well so far my N8 adventure. After daily irritations of Nokia Messaging not 'push'ing my e-mail. My N8 suddenly became non-responsive and then went dark. And now it's dead. Even hard reset (key combination) doesn't work anymore.

  • IE Freeze when running applet on JRE 1.4.2_06

    When i run my applet on IE 6 with JRE 1.4.2_06 and try to close IE window it freezes the IE window, while if i run the same code in 1.4.1_05 it works fine. The OS is windows 2000 Professional and IE is 6.0.2800.1106. Also the same applet works fine o

  • Remove Duplicate Emails from the server

    Several users have multiple copies of the same message in their inbox. Collecting External Mail and then copying the same email. Is there a way to look for duplicate messages and then delete them?

  • Problems with groups in OBI EE 10.1.3.3

    Hi I have been worked in the configuration LDAP integration with OBI EE. I have access to OID LDAP server fine and I Can login in Answers with my LDAP user. I have a PLSQL procedure that work with the DBMS_LDAP package for read the GROUP information