Create a table which has columns from another table in other schema

Hi All
I need to create a table which is table driven i.e., the columns of that table need to be inserted from another table in a different schema...Can any one help me with this??

create table newtab (--column spec here--) as
Select --columns here-- from otherschema.tablename;max

Similar Messages

  • Insert into a table with unique columns from another table.

    There are two tables,
    STG_DATA                                                          
    ORDER_NO    DIR_CUST_IND
    1002                     DNA
    1005                     GEN
    1005    
    1008                     NULL
    1001                     NULL
    1001                     NULL
    1006                     NULL
    1000                     ZZZ
    1001                     ZZZ
    FACT_DATA
    ORDER_NO    DIR_CUST_IND
    1005                      NULL
    1006                      NULL
    1008                      NULL
    I need to insert only unique [ORDER_NO] from STG_DATA to FACT_DATA with corresponding [DIR_CUST_IND]. Though STG_DATA has multiple rows with same ORDER_NO, I need to insert only one of that it can be any record.
    Sarvan

    CREATE TABLE #Level(ORDER_NO INT, DIR_CUST_IND CHAR(3))
    INSERT #Level
    SELECT 1002,'DNA' UNION
    SELECT 1005,'GEN' UNION
    SELECT 1005,NULL UNION
    SELECT 1008,NULL UNION
    SELECT 1001,NULL UNION
    SELECT 1001,NULL UNION
    SELECT 1006,NULL UNION
    SELECT 1000,'ZZZ' UNION
    SELECT 1001,'ZZZ'
    SELECT ORDER_NO,DIR_CUST_IND
    FROM( SELECT ROW_NUMBER()OVER(PARTITION BY ORDER_NO ORDER BY ORDER_NO) RowNum,*
    FROM #Level)A
    WHERE RowNum=1
    I hope this would give you enough idea. All you have to do is just write insert statement.
    Next time please post DDL & DML.
    Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
    The climb is all there is.

  • How to update table which has column name as Oracle keyword?

    Hi All,
    Somebody has created one table which has column name as "OPTION", now i am trying update this table column value and its throwing an error. "Invalid Identifier".
    Could you please help me in this?
    Thanks in advance.
    Regards,
    Ganesh Patil

    check this :
    batch@DOLN1> create table "from" ("select" varchar2(10));
    Table created.
    batch@DOLN1> desc "from";
    Name                                                                                                  Null?    Type
    select                                                                                                         VARCHAR2(10)
    batch@DOLN1> update "from" set "select" = 'hello World';
    0 rows updated.
    batch@DOLN1> insert into "from" values('hello World');
    insert into "from" values('hello World')
    ERROR at line 1:
    ORA-12899: value too large for column "TCM_BATCH"."from"."select" (actual: 11, maximum: 10)
    batch@DOLN1> update "from" set "select" = 'hello';
    0 rows updated.
    batch@DOLN1> insert into "from" values('hello');
    1 row created.
    batch@DOLN1> commit;
    Commit complete.
    batch@DOLN1> update "from" set "select" = 'World' where "select" = 'hello';
    1 row updated.
    batch@DOLN1> select * from "from";
    select
    World

  • Looping delete statement where table name is coming from another table

    Hi All,
    We have to write code to delete records from active tables of WDSO.We have 5 DSO  so inspite of writing delete statement for each table we want to put all table names into one table and then loop through it .but we are getting error when we are refering that table field which has active table name.error is :
    "dictionary structure or table is either not active or does not exist "
    As per my understanding in a delete /select /insert /update statement we need to put table name (whose field we are refering ) it can't be replaced by a variable .
    ex: v_table = 'EMPLOYEE' .
    DELETE FROMv_table WHERE EMP_NAME = 'ABDC' .
    is wrong and it must be like
    ex : DELETE FROM EMPLOYEE WHERE EMP_NAME = 'ABDC' .
    but we want to make our code dynamic .
    Can you please suggest a way so that we can read the table names from another table and delete data based on some selection fom those tables .
    I tried variants ,perform etc and even searched FM for the same but not found a solution .Your help will be greatly appreciated .
    Thanks in advance .
    Regards,
    Jaya

    Hi,
    You can change your statement as follows:
    DELETE FROM (v_table) WHERE EMP_NAME = 'ABDC' .
    However, I would not recommend this. There is a standard function module RSAN_ODS_DATA_DELETE which allows selective deletion - that should be a safer way to do this. You can

  • Procedure to insert data into table by selecting data from another table

    Hi all,
    I have to create a procedure where i have to select the data from one table and insert it into another table. Any help on this. And i have to update the 2nd table also when ever new records got inserted in the 1st table then.
    Regards

    Hi, you can try something like:
    CREATE [OR REPLACE] PROCEDURE procedure_name
    IS
    BEGIN
    INSERT INTO TABLE1
    VALUES (SELECT * FROM TABLE2);
    END;
    For the other part you may create a trigger on the first table AFTER INSERT to insert the values in the second table too.

  • UPDATING A TABLE WITH SAME INFO FROM ANOTHER TABLE ON THE SAME DB

    0down votefavorite
    I am trying to update a table with info from another table on the same db with same table name. I just want the info to be the same , no primary key or constraint involve just a straight replacement of records and I keep getting errors WITH THE TABLE not
    being recignize. below is my query:
    UPDATE
    VNDFIL
    SET EOBTYP
    =  VNDFIL.EOBTYP, 
    EDI_X12_835_VERSION =  VNDFIL.EDI_X12_835_VERSION
    FROM
    AGERECOVERY
    WHERE
    VNDFIL.EOBTYP
    = VNDFIL.EOBTYP
    AND
    VNDFIL
    .EDI_X12_835_VERSION
    = VNDFIL.EDI_X12_835_VERSION

    Hi rotary,
    If those two same named tables are in the same database then they have to be in different schemas. If you mean they are in the same server instance, then they may be in different databases, besides the "table not being recognized" error,
    anyway you should use the fully qualified table names, that is database.Schema.Table(If across instances, ServerName should be prefixed) to avoid the table unrecognized error.
    Using Identifiers As Object Names
    With the fully qualified names, your update statement can be like below.
    UPDATE
    db1.schema1.VNDFIL
    SET EOBTYP = srcTbl.EOBTYP, EDI_X12_835_VERSION = srcTbl.EDI_X12_835_VERSION
    FROM
    db1.schema2.VNDFIL srcTbl
    WHERE
    db1.schema1.VNDFIL.EOBTYP = srcTbl.VNDFIL.EOBTYP AND
    db1.schema1.VNDFIL.EDI_X12_835_VERSION = srcTbl.VNDFIL.EDI_X12_835_VERSION
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Breakout table (fill table with matching data from another table)

    Hi
    I've been trying to study old discussions about breakout tables. I feel I'm close, but still no cigar :-)
    In plain english, I'm trying to autocreate rows with data on a table, based on matching values from another table. E.g. have a table to display all rows where type = AssetX
    I have attached a screenshot of my "master table" called Assets:
    I'm looking to prefill Asset name, Total from this table and populate a new table called e.g. Greenhouse
    Where I'd be adding more data (date, income, expense).
    Any help whould be greatly appreciated.
    Thanks!

    Hi,
    Here is a Sample Query.
    Update Emp A
    Set Sal = (Select Sal from emp b where
    a.empno = b.empno)
    where empno in (select empno from emp);
    Regards,
    Ganesh R
    null

  • Retrieving numeric values of a column from another table..

    Hi there, so i have the following query that returns a label and a value from a database table:
    select key_field,value_field from table1 where some_id = 'id1' and key_field is not null;
    This will return a result in which the key_field may or may not be numeric, which is fine:
    key_field | value_field
    2 | street
    6 | dog
    car | mazda
    5 | tea
    1 | unknown
    I have another table table_num_vals where the value for those numeric fields are stored:
    key_field | display_field
    2 | address
    6 | animal
    5 | drink
    I want to be able to return the non-numeric fields as they were, all numeric fields translated if it can be found, and if not then leave the original number, desired result:
    key_field  | value_field
    address | street
    animal | dog
    car | mazda
    drink | tea
    1 | unknown
    I tried doing the following:
    select display_field from table_num_vals where key_field in (
        with numericCol as (
            select key_field from table1 where some_id = 'id1' and key_field is not null;
        ) select case when regexp_like(key_field,'^[[:digit:]]') then key_field else '' end from numericCol
    It gives me the labels for the ids that it can find.. (address, animal, drink) but then I can't seem to put it all together with the original query.. could someone please help?
    Thanks in advance,

    Yes you are right .. Thank you so much
    I let it work using
    select student_ID, Level from Student where Level ='Graduate'
    But when i run different kind of form to Graduate_Student table and try to create a new row , I cant see the Student_ID  !  I see it only if I use Form using SQL but this one doesn't add/delete/update record.
    I am new to oracle apex, sorry for that.

  • Auto Populate Field in One Table with Primary Key from another table.

    Greetings all,
    I have created two tables. One for Root Cause which will be the based description information of an analysis. Each Root cause can have many corrective actions.
    My Table structure is as follows:
    RCCA TABLE:
    =====================================
    Column Name     Data Type     Nullable
    RCCAID     NUMBER     No
    DESCRIPTION     VARCHAR2(4000)     Yes
    SUMMARY     VARCHAR2(4000)     Yes
    OWNER     VARCHAR2(4000)     Yes
    DATEOFINCIDENT DATE     Yes
    STATUS     VARCHAR2(4000)     Yes
    CORRECTIVE ACTION TABLE
    =====================================
    Column Name     Data Type     Nullable
    CAID     NUMBER     No
    RCCAID     NUMBER     No
    CANUMBER      NUMBER     Yes
    CACTION     VARCHAR2(4000)      Yes
    DATEDUE     DATE     Yes
    COMMENTS     VARCHAR2(4000)      Yes
    So I have a form that creates the RCCA and then I have another form that I want to feed off of the first form. My thought was that when the RCCA was created, it would open a report of the RCCA and then in another region of the page I would add corrective action form. What I am looking to do is when I press the Create Corrective Action, it will automatically populate the RCCAID in the Corrective Action Table so that it is associated directly to the RCCA. I don't want to have to have someone know what the RCCAID is from teh RCA table because they are autogenerated.
    There may be a better way to do this and since I am new to APEX and to Oracle Databases, I am just going with what my logic tells me. Any assistance or thoughts would be appreciated.
    Assuming there would be some type of trigger?
    I will have to be able to view each RCCA and CA in a report that customers will see.
    Thanks in Advance
    Wally

    Hi Debasis,
    Have a look on this
    Quick note on IDENTITY column in SAP HANA
    Regards,
    Krishna Tangudu

  • Ain't getting it: insert into table by determing value from another table

    I have a table (PERCENTILE_CHART) with percentiles and test scores for different tests:
    Structure:
    Percentile, Reading_Test, Writing_Test
    Data:
    30,400,520
    31,450,560
    97,630,750
    98,630,780
    99,640,800
    The data is currently in ascending order by Percentile.
    If a person took the Reading test and scored 630 he or she would be in the 98th (not 97th) percentile of the class taking that test.
    I wrote a statement to return the percentile:
    select Percentile
    from ( select ROWNUM, PERCENTILE
    from PERCENTILE_CHART
    where READING_TEST <= '650'
    order by READING_TEST desc)
    where ROWNUM < 2 order by PERCENTILE desc;
    This select works and is able to determine the highest percentile for a score.
    Ok, now I want to process all the records in a STUDENT table which have
    test scores and insert them in a new table along with the percents, normalizing the data in the process.
    Have this:
    STUDENT:
    Student_Name,Student_ID,
    John Smith,121,Reading,98,Writing,90
    Maggie Smithe,122,Reading,95,Writing,96
    And needs to be moved to into SCORES with the percentiles, so I get this:
    SCORES:
    Student_Name,Student_ID,Test_Name,Percentile
    121,Reading,98
    121,Writing,90
    122,Reading,95
    122,Writing,96
    This is were I get confused. How do I insert the data into the SCORES table with the percentile? I think calling a function in package is the way to do it:
    function oua_Test_Percentile_f (
    p_Test_Name in char,
    p_Test_Value in char)
    return char as
    -- Declare variables
    c_Return_PTile char(2);
    begin
    select PERCENTILE into c_Return_PTile
    from (select ROWNUM, PERCENTILE
    from PERCENTILE_CHART
    where p_Test_Name <= '&p_Value'
    order by p_Test_Nmae desc)
    where ROWNUM < 2 order by PERCENTILE desc;
    return c_Return_PTile;
    end;
    But this function doesn't return the percentile even though it is based on my working select mentioned earlier. It returns a blank for all tests.
    And even if it is working how do I then populate the SCORES table?

    You may want to use analytical functions so that you can determine the percentile across all of the different scores:
    SQL> with
    2 PERCENTILE_CHART as
    3 (
    4 select 30 PERCENTILE, 400 READING_TEST, 520 WRITING_TEST from dual union all
    5 select 31 PERCENTILE, 450 READING_TEST, 560 WRITING_TEST from dual union all
    6 select 97 PERCENTILE, 630 READING_TEST, 750 WRITING_TEST from dual union all
    7 select 98 PERCENTILE, 630 READING_TEST, 780 WRITING_TEST from dual union all
    8 select 99 PERCENTILE, 640 READING_TEST, 800 WRITING_TEST from dual
    9 )
    10 select
    11 max(percentile) over (partition by reading_test) HIGHEST_READING,
    12 max(percentile) over (partition by writing_test) HIGHEST_WRITING,
    13 percentile_chart.*
    14 from
    15 percentile_chart
    16 /
    HIGHEST_READING HIGHEST_WRITING PERCENTILE READING_TEST WRITING_TEST
    30 30 30 400 520
    31 31 31 450 560
    98 97 97 630 750
    98 98 98 630 780
    99 99 99 640 800
    SQL>
    I wasn't exactly sure how you wantd to coorelate this to the student records though; the student table had only two column name headings but there were four rows listed as examples and had fewer rows than in the percentile_chart table...
    If you join the student table to the able query it might be what you are looking for.
    You can create another table based on the output of your query by doing:
    create table scores
    as select * from
    (insert your query here)
    /

  • Show name from one table, and a sum from another table.

    Hi,
    For instance: I have 2 tables.
    1. Table1 has fields TenantID, TenantName,
    2. Table2 has fields AmmountCredit, AmmountDebit, TenantID.
    I need the following behavior.
    In the detailed section I want my report to show a list of TenantName, and a SUM of AmmountCredit minus Ammount Debit for that Tenant (which will come from Table2).
    How would I do this?  If a formula is involved, please provide an example because I'm fairly new to Crystal Reports.
    Thanks
    Aron

    Hi Aron,
    Please see if this helps:
    1) Go to the Database Expert > Add the two tables > Go to the Links tab > Join the two tables on the 'Tenant ID' field using an 'Inner Join' > Click OK
    2)  In the report, go to the Group Expert and create a group on the 'Tenant ID' field
    3) Place the 'Tenant Name' field on the Group Header 1
    4) Suppress the Details Section
    5) Create a formula with this code and place it on the Group Header 1:
    Sum({AmountCredit}, {TenantID}) - Sum({AmountDebit}, {TenantID})
    Here, {TenantID} is the Group field. So replace these fields with the right fields from your datasource.
    -Abhilash

  • How to populate rows in the detail table of a form from another table.

    please can someone help me here:
    i have a master/detail page. the master data is created and then i would like to do this: when one goes to the detail page (when first created), i would like somehow to populate all the rows in the detail table from rows retrieved in another table (with conditions).
    i am new to apex so if this is a stupid question i apologise in advance!

    Hi
    Firstly, there are no stupid questions, we all start somewhere!
    However, I could do with some more detail (or even better an example on apex.oracle.com). Please can you post exactly what you have so far and what you want to achieve with simple details of the tables involved.
    It sound like you may need to create a custom process to populate the details. You say 'with conditions'... what conditions?
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • How to insert a row in Tree table which is dragged from the table?

    Hi All,
    I am having a Tree table and a Table in the same page, like below
    Treetable                                         Table
    Item1                                              Subitem12
         Subitem1                                   Subitem13
         Subitem2                                   Subitem14
         Subitem3                                   Subitem15
         Subitem4                                   Subitem16
    Item2                                              Subitem17
         Subitem5                                   Subitem18
         Subitem6                                   Subitem19
         Subitem7                                   Subitem20
         Subitem8                                   Subitem21
    Item3
         Subitem9
         Subitem10
         Subitem11
    The requirement is i need to "drag" a row from the Table and place it under any parent node in the Tree table.
    What i have done is I make the Tree table as ".ui-sortable" and table as a "draggable".
    I am not able to find the position of the dragged item when i dropped it in the Treetable.
    Please provide me a solution.
    Regards,
    Aravindh

    Hello:
    Do you mean setting the selectedRowKeys in the setter method of the treeTable in the Request Scoped Managed Bean?
    If that is what you mean, I tried that and there was no change in behavior. (Still does not highlight the correct row in the tree table upon execution of the next method for the bindings) Does anyone have any sample code they can provide that works?
    Thanks for the help.

  • Update one table based on condition from another table using date ranges

    Hello!
    I have two tables:
    DateRange (consists of ranges of dates):
    StartDate            FinishDate
            Condition
    2014-01-02
          2014-01-03           true
    2014-01-03     
     2014-01-13          
    false
    2014-01-13      
    2014-01-14           true
    Calendar (consists of three-year dates):
    CalendarDate    IsParental
    2014-01-01
    2014-01-02
    2014-01-03
    2014-01-04
    2014-01-05
    2014-01-06
    2014-01-07
    2014-01-08
    2014-01-09
    2014-01-10
    I want to update table Calendar by setting  IsParental=1
      for those dates that are contained in table DateRange between
    StartDate and FinishDate AND Condition  IS TRUE.
    The query without loop should look similar to this but it works wrong:
    UPDATE
    Calendar
    SET IsParental = 1
     WHERE
    CalendarDate   BETWEEN
    (SELECT
    StartDate 
    FROM  DateRange
    WHERE Calendar.  CalendarDate   = DateRange. StartDate
               AND   
    (SELECT StartDate 
    FROM  DateRange
    WHERE Calendar.  CalendarDate   = DateRange. FinishDate
    AND Condition
     IS TRUE
    Is it possible to do without loop? Thank you for help!
    Anastasia

    Hi
    Please post DDL+DML next time :-)
    -- This is the DDL! create the database structure
    create table DateRange(
    StartDate DATE,
    FinishDate DATE,
    Condition BIT
    GO
    create table Calendar(
    CalendarDate DATE,
    IsParental BIT
    GO
    -- This is the DML (insert some sample data)
    insert DateRange
    values
    ('2014-01-02', '2014-01-03', 1),
    ('2014-01-03', '2014-01-13', 0),
    ('2014-01-13', '2014-01-14', 1)
    GO
    insert Calendar(CalendarDate)
    values
    ('2014-01-01'),
    ('2014-01-02'),
    ('2014-01-03'),
    ('2014-01-04'),
    ('2014-01-05'),
    ('2014-01-06'),
    ('2014-01-07'),
    ('2014-01-08'),
    ('2014-01-09'),
    ('2014-01-10')
    select * from DateRange
    select * from Calendar
    GO
    -- This is the solution
    select CalendarDate
    from Calendar C
    where EXISTS (
    select C.CalendarDate
    FROM DateRange D
    where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
    UPDATE Calendar
    SET IsParental = 1
    from Calendar C
    where EXISTS (
    select C.CalendarDate
    FROM DateRange D
    where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
    [Personal Site] [Blog] [Facebook]

  • To select table which has TAB as data column with in

    Hi All
    I have a table which has column type defined as TAB type. When I try selecting the table in PL/SQL developer, I got below error.
    What should I do? Even SQL* Plus shows the same error!
    SQL> select *
      2  from my_tab_cap
      3  /
    from my_tab_cap
    ERROR at line 2:
    ORA-00904: : invalid identifierThanks in advance.
    Message was edited by:
    guru paran
    Changed the table name.

    You probably want to help us out with all your ddl:
    create table tab2 (my_tab_col my_type ) nested table my_tab_col store as my_tab;
    create type my_type as table of varchar2(100);
    declare
    v_type my_type := my_type();
    begin
    v_type.extend(4);
    v_type(1) := 'I like table types1';
    v_type(2) := 'I like table types2';
    v_type(3) := 'I like table types3';
    v_type(4) := 'I like table types4';
    insert into tab2(my_tab_col) values (v_type);
    end;
    select * from tab2;
    MY_TAB_COL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    VARCHAR(I like table types1,I like table types2,I like table types3,I like table types4)     

Maybe you are looking for

  • Blue screen appears during start up and freezes

    During start up the apple logo appears and locks up. Re booting results in blue screen. After re booting 3 or 4 times finally boots fine.

  • TC F110 - Protect the variant for the Print out/ data medium - RFFOIT_FOR

    Hi Experts, I have to protect the field "filename" in the program RFFOIT_FOR and I have to permit to user, when he runs the TC F110, to change only some field in the variant for the same program. Can you help me? Thanks in advance. Best Regards Giamp

  • Quicktime audio sync issues

    Hello, I have quicktime version 10 (128).   I can't get anything to play in it without there being severe audio sync issues every time.  I can't figure out why.  Can someone please help me fix this problem?  When I export my movies from imovie to qui

  • Cannot find servlet

    I am using apache tomcat i have my web application folder at the Root level i-e my folder named jsp-scripting is at the same level as Root folder of webapps. In jsp-scripting folder, i have WEB-INF/classes folder where i have put my servlet classes i

  • Re:migrating EBS from 11.5.8 to 11.5.10.2

    Hi , Is there any document which can give the functional changes between 11.5.8 and 11.5.10.2 . Regards .