Records insert differently with FK?

I have a parent and child with a foreign key (nothing special, just alter table add constraint foregin key). If I add the FK 1st then populate both tables, a join takes 4+ seconds. If I populate 1st then add the FK, the join is almost instant.
Is Oracle inserting them differently when there's a FK?
or is one way creating an implicit index?

Yep, forgot to do the most basic test. The weirdness of it threw me off. One join is doing 2 full table scans, the other is using the unique index. There's gotta be something different about the two tables. Just not seeing it...

Similar Messages

  • INSERT of two records into different tables (pk value from first to second)

    Hi there!
    Have probably stupid question
    Need to insert one record into table with primary key and then insert into other table record with value of primary key field from first record
    How can I do it?
    Thanks a lot!!!

    You have several possibilities. Most easiest one is listed first :)
    SQL> create table a (a number);
    Table created.
    SQL> alter table a add constraint a_pk primary key (a);
    Table altered.
    SQL> create table b (a number);
    Table created.
    SQL> alter table b add constraint  b_a_fk foreign key (a) references a(a);
    Table altered.
    SQL> insert into a values (0);
    1 row created.
    SQL> insert into b values (0);
    1 row created.Though that may not help always, so the next possibility maybe just using sequence with nextval and currval (currval can be used only in the same session and only after you have issued at least one nextval)
    SQL> create sequence a_seq;
    Sequence created.
    SQL>  insert into a values (a_seq.nextval);
    1 row created.
    SQL> insert into b values (a_seq.currval);
    1 row created.And you can use also famous returning clause. It is a bit easier to show that in the pl/sql block than pure SQL.
    SQL> declare
      2   v number;
      3  begin
      4   insert into a values (a_seq.nextval) returning a into v;
      5   insert into b values (v);
      6  end;
      7  /
    PL/SQL procedure successfully completed.And at last contents of the tables :)
    SQL> select * from b;
             A
             0
             1
             2
    SQL> select * from a;
             A
             0
             1
             2Gints Plivna
    http://www.gplivna.eu

  • Assign records to different remote systems in MDM

    Hello Experts,
    I am using qualified range to generate internal number range for vendor. The remote key & remote system details for the records are generated during syndication. My scenario is that I have couple of records in MDM for different remote systems. I want to syndicate it to the respective systems. Is there a way to identify the respective records per system with out inserting the details in "edit key mapping".
    If we try specifying Remote system details in edit key mappings with a blank or specific Key value , then the qulaified number generated for vendors is overwritten with this key value mentioned in key mapping.
    I need to retain both the qualified range functionality as well as tag the records to different remote systems.
    Kindly advice.
    Thanks and Regards,
    Elizabeth.

    Hi Shiv
    So, i am not sure, but this all makes me feel that syndication tasks can not be executed parallel.
    Your understanding here is correct since we are using here the same table for syndication process so it will be executed in steps. I mean syndication 2 has to wait until the syndication 1 ends. But the thing is that even after syndication 1 completes syndication 2 is not going to place that's the issue here.
    Please find solution which tells same thing in MDM import manager context.
    Can I run two Import Managers at the same time?
    Yes, several instances of the Import Manager can be open concurrently. The only existing limitation though is when actual importing process starts the tables involved in the importing process are locked for write access. So if two instances of the Import Manager import to different tables then no synchronization issue occurs. If they use the same table, then the instance getting access second has to wait until the first ends.
    For more details, Please refer this below link:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/7dc6ba86-0501-0010-0b82-849437929f0d?quicklink=index&overridelayout=true
    @ Elizabeth: After Syndication 1, Have you checked after sometime whether syndication2 & so-on takes place or not. I feel that Syndication for syndication 2 , syndication 3 & syndication 4 should also occur after some time as they executed one by one not parallel so will take some time. Just check and revert with result whether your workflow gets completed after some time or not.
    Note: Make sure that for all these Syndications outbound ports Processing Type = Manual in Console else syndication will not occur.
    Regards,
    Mandeep Saini

  • Need to commit after every 10 000 records inserted ?

    What would be the best way to Commit after every 10 000 records inserted from one table to the other using the following script :
    DECLARE
    l_max_repa_id x_received_p.repa_id%TYPE;
    l_max_rept_id x_received_p_trans.rept_id%TYPE;
    BEGIN
    SELECT MAX (repa_id)
    INTO l_max_repa_id
    FROM x_received_p
    WHERE repa_modifieddate <= ADD_MONTHS (SYSDATE, -6);
    SELECT MAX (rept_id)
    INTO l_max_rept_id
    FROM x_received_p_trans
    WHERE rept_repa_id = l_max_repa_id;
    INSERT INTO x_p_requests_arch
    SELECT *
    FROM x_p_requests
    WHERE pare_repa_id <= l_max_rept_id;
    DELETE FROM x__requests
    WHERE pare_repa_id <= l_max_rept_id;

    1006377 wrote:
    we are moving between 5 and 10 million records from the one table to the other table and it takes forever.
    Please could you provide me with a script just to commit after every x amount of records ? :)I concur with the other responses.
    Committing every N records will slow down the process, not speed it up.
    The fastest way to move your data (and 10 million rows is nothing, we do those sorts of volumes frequently ourselves) is to use a single SQL statement to do an INSERT ... SELECT ... statement (or a CREATE TABLE ... AS SELECT ... statement as appropriate).
    If those SQL statements are running slowly then you need to look at what's causing the performance issue of the SELECT statement, and tackle that issue, which may be a case of simply getting the database statistics up to date, or applying a new index to a table etc. or re-writing the select statement to tackle the query in a different way.
    So, deal with the cause of the performance issue, don't try and fudge your way around it, which will only create further problems.

  • Dreamweaver CS4 - Record Insertion Form js error

    Hi
    I'm dreamweaver cs4 and started using the Record Insertion form, I was mainly experimenting with it and just seeing what it could do.
    However when I get to the wizard i have to wait a few seconds for it to connect to the database and then I get an error message that says:
    While executing onLoad in ServerObject-InsRecPHP.htm, the following Javascript error(s) occured:
    At line 283 of the file "Macintosh HD:Application:Adobe Dreamweaver
    CS4:Configuration:Commands:ServerObject-FormCmnPHP.js":
    invalid array length
    I was just wondering if this was a common problem, or I've messed something up either in Dreamweaver, or in the SQL database that I'm using.
    I've also noticed that its the same for Update and Delete Records Wizards aswell.
    Any help would be greatly appreciated
    Aaron Kennedy

    I see it's your first post. Welcome to the forum.
    A good place to start looking for answers is the Dreamweaver FAQ. You'll find the answer to your question under "Crashes, installation, JavaScript, and unexplained problems".

  • Inserting data with the help of nested table...!!!

    The following block is giving error
    ORA-06502: PL/SQL: numeric or value error
    the signature and signature_bkp have the same structure
    So, can anybody help me out to solve this issue :
    for copying records from one table to another table
    Thanking You advancely
    DECLARE
    CURSOR c1
    IS
    SELECT *
    FROM signature
    WHERE creation_time > TRUNC ( SYSDATE ) - 100
    AND ROWNUM < 102;
    TYPE sig_typ IS TABLE OF signature%ROWTYPE;
    sig_t sig_typ;
    BEGIN
    OPEN c1;
    FETCH c1
    BULK COLLECT INTO sig_t;
    CLOSE c1;
    FORALL i IN sig_t.FIRST .. sig_t.LAST
    INSERT INTO signature_bkp
    VALUES sig_t ( i );
    COMMIT;
    END;
    --DKar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Or whether a INSERT statement with SELECT clause will do that for youby using this technique, it took 47:08:45 to copy 7252 rows
    and by using a cursor for loop took 49:03:23 to copy 13567 rows
    So there was appox. 40% increase in performance by using pl/sql. I thought it could be even faster using the bulk-bind ing features and nested tables.
    OR i just want to know ....how to correct the block of code that was given in my 1st msg without changing its logic.
    Thanks
    --DKar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can i use same customer master record in different sales area

    dear sir,
    i have created a record of customer master - RAM in sold to party account group using sales area - (I).
    (i.e,) XYZ ( sales org ) - A (dis channel ) - XX ( division)
    now i have created another record of customer master - DAVID in sold to party acc group using sales area - (II).
    (i.e) XYZ (sales org) - A (dis channel ) - YY ( division ).
    when i am trying to change SH party function of "RAM" with "DAVID" its throwing an error message that DAVID is not created in Sales Area - (I).
    please let me know how to resolve this
    regards
    vivek

    Hi,
    There are two solution to control this.
    1) Extend customers in respective sales area. i.e.. DAVID in XYZ-A-XX or RAM in XYZ-A-YY.
    2) Define reference sales organisation, channel and division and assign to respective.
    EX.      
    Define sales org. "0000" and assign to all sales orgs.
    Define channel "00" and assign to all channels.
    Define division "00" and assign to all divisions.
    Now create customer masters only in sales area 0000-00-00 and you can use this customer anywhere for any sales area (at transactional level). This is one time activity and will save so much time in creating(or extending) master records in different sales area.
    Thanks,
    Tarpan

  • How can I record a video with LAbview?

    Hi,
    I have a question: How can I record a video with labview?
    I have a camera (AXIS 221) connected via rj45 on PC. I see the video of the camera in a browser.
    And I would to acquire the video in labview.
    Could someone help me?
    Thanks
    Raf

    Unfortunately I haven't any experience with this camera. Iguess, you should install API, then crete new VI, place ActiveX container (palette Container->ActiveX) on the Front Panel, then right mouse click, then choose Insert ActiveX object..., then found you camera object and select it and press OK. Then you probably can see image from the on the front panel. Also probably you will be able to get image data in array (how easy is it - depends from the camera API).
    If you able to see image from camera in the Internet Explorer, then another method - you can put Microsoft Web Browser as ActiveX object, then you should also see the image. Disadvantage of this method - you will be not able to get image data.
    Andrey.

  • How to determine the last record inserted

    hi
    I have a table abc ( x number, y number, z date ) columns, there
    is no primary or unique key.
    I have been inserting values into it. there r some duplicate
    values to.
    but now I want to modify only the record inserted at the end.
    i.e
    if initially ABC is having
    x y z
    10 20 01-nov-2001
    11 20 01-nov-2001
    out of these records I want to change the value of x to 50 for
    the record which was inserted last or shall I say whose z is the
    greatest.
    I have been trying to do but what I see that the z column is not
    getting the time in increasing order. i.e even though I tried to
    display the dated in dd-mon-yyyy 24hh:mm:ss format still and I
    found that date is not consistant. the record I inserted first
    is have a much more value than the record I inserted last.
    please help...
    Sreekant

    rowid refers to the current position of the record; if the
    record has been moved (and there are any number of reasons why
    the database might shift a record) the order of rowid will not
    reflect the order of insertion.
    the only way to guarantee order of insertion is to timestamp the
    record. if I understand the original posting, you have been
    doing this.
    Now you should have been using SYSDATE. if you are saying that
    SYSDATE is giving you inconsistent results then you have a real
    problem: has somebody been tinkering with your database server -
    changing the system clock or something?
    Or are you using some other method to set the value for Z
    column? If so, what?
    rgds, APC

  • How to upload 15 lakhs of record onto ztable with performance

    I have 15 to 20 lakhs of records in my internal table. I'm uploading it onto ztable in se11.
    While doing so, it's taking lot of time.
    I'm writing the following query:
    MODIFY ZTABLE       FROM TABLE  ITAB(INTERNAL TABLE NAME).
    Please let me know if there is any other alternative which gives better performance.
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Feb 2, 2010 11:59 AM

    Hi Rob,
    just trace a
    MODIFY ZTABLE FROM TABLE ITAB
    with ST05 and you will see what the DBI / DB does with this statement.
    If i remember right you are on DB6. Given current releases it migth be possible
    that a MERGE (which can handle arrays) will be used instead of UPDATE / INSERT on
    a row by row basis.
    On most platforms the modify from table is done row by row like this:
    UPDATE dbtab_row.
    IF sy-subrc NE 0.
       INSERT dbtab_row.
       IF sy-subrc NE 0.
          UPDATE dbtab_row.
       ENDIF.
    ENDIF.
    if the rows exist you will only see updates.
    if the rows don't exist you will see updates (no record) followed by an insert (1 record).
    In rare cases you might see update (no record), insert (no record, somebody else inserted this record after the first update), update (1 record).
    Kind regards,
    Hermann

  • SQL Script working differently with 8i and 9i

    Hi
    I am facing strange problem with my simple SQL script called from a shell script. It bahaves differently with ORACLE 8.1.7.4 and 9.2.0.1. The machine is same.
    sqlplus -s / @Tech.sql WKC625 11 11 '11 22' ""
    This is working with 9i but it does't work with ORACLE 8.
    Actually what happens is that the argument in single quotes (') is taken as 2 separate argument.
    The Tech.sql is :
    spool add
    insert into TECH values ('&1','&2','&3','&4','&5','');
    commit;
    quit
    I tried putting double quotes also. Is something got changes between ORACLE 8 and 9i.
    Please help
    Surendra

    Are you sure it works in 9?
    If you are using UNIX, then the O/S will strip the quotes while processing the arguments. You need to use 2 single quotes around 11 22, just as you have around the empty string at the end.
    I believe that Windows does the same, but I do not use windows.
    John

  • Errors not logged when IKM Oracle Multi Record Insert is selected

    Dear All,
    I am new in ODI 11g and I am facing the following problem:
    I created a package with 3 Interfaces with Oracle Multi Record Insert.
    In the first interface I load the source data to a temporary target
    In the second interface target#1 table is loaded using interface#1
    In the third interface target#2 is loaded using interface#1 and the multiple insert is executed and committed.
    This works correctly, but when a data error occurs (e.g. mandatory column is null), instead of the error being logged in the Error table, execution of the last interface fails with the following error:
    Caused By: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into (<schema>.<table>.<column>)
    I noticed that when I use Oracle Incremental Update instead, the errors get logged correctly in the error table.
    Does anyone know what could be causing this?

    Hi Bhabani,
    Thanks for the reply.
    I am afraid that this is a major issue for me, I do not want to re-query the source table for each target table, but on the other hand I cannot fail the process for each invalid record and I need the logging.
    Can you think of a workaround for my use case?
    Thank you!

  • Insert statement with Date, time into Oracle

    Hi,
    I've got the following statement that I'm trying to insert into Oracle. Actually had to change up the format to dd-mm-yy to get it to insert the date correctly, not sure why, but I've got it "supposedly" formatted to also insert the hours, min., seconds into the db record, but it's not catching it.
    My code:
    INSERT INTO VOTETBL
    (CHANGE_CTRL_ID,BUSVP,BRANCH,VOTE,VOTE_TIMESTAMP)
    VALUES (?, ?,?,?,to_date(sysdate, 'dd-mm-yy hh24:mi:ss'));Shouldn't the sysdate capture all those elements sufficiently? The day, month, year get inserted correctly with this, but not so for the time portion.
    Any suggestions is welcomed.
    Thx.

    ok, thanks.
    I tried making a result set with the following:
    Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet rst = stmt.executeQuery("select to_char(sysdate) from dual");
    Date dualtimestamp = (rst.getDate("sysdate"));But it makes the servlet blow up! Not sure why either, because if I enter that exact statement in Oracle, it pulls back the date and time just like I aim to. But not embedded in the result set statement within the servlet.
    It breaks up somehow and doesn't get that result!

  • Update/Insert Problem with Oracle Warehouse Builder

    Hello,
    i have update/insert problem with owb.
    Situation: I have a source-table called s_account and a target table called w_account_d. In the target table are already data which was filled trough the source table inserts. Now anyone make changes on data on the target table. This changes should now give further on the source table with an update operation. But exactly here is the problem i can´t map back the data to source because that will create a loop.
    My idea was to set a trigger but i can´t find this component in owb or is anywhere hidden?
    Also i have already seen properties as CDC or conditonal loading in the property inspector of the table, but i have no idea how it works.
    Give it other possibilities to modeling this case? or can anyone me explain how i can implement this eventually with CDC?
    I look forward for your replies :)

    Hi
    thanks for your answer. I follow your suggestion and have set the constraints of both tables into the database directly.Nevertheless it doesn´t work to begin. In the next step i found by right click on a table the listpoint "configure" - I goes to "unique key" --> creation method and set here follow options: Constraint State = ENABLE, Constraint Validation = Validate. That error message that appears before by the deployment disappears yet. Now i start the job to test if the insert/update process works right. Finally it seems to work - but not really.
    My Testscenario
    1. Load the data from source table about the staging area to data warehouse table: Check - it works!
    2. Change one data record in source table
    3. Load the source table with changed data record once again to staging area: Check - it works!
    4. Load new staging area table with the changed data record to data warehouse table: Check it works! BUT, BUT i can not recognize if it is insert or update operation, then under the design window by jobs execution windows is reported "rows selected 98", Rows inserted" is empty and "rows updated" is empty. So i think works not correct, then my opinion if it works correct it should show be "rows updated" 1.
    What can yet now still be wrong or forgotten? Any ideas?
    *By the way think not 98 rows there is not important if you make an update or insert which performance. It is an example table the right tables have million of records.*
    I look forward for your answers :)

  • Rejected records into different Table.

    Hi ,
    I have a .ctl file and .txt file. for the normal scenario, I use SQLLDR to load data into my table using ctl file and all rejected records will be sent to bad files. But I wanted all the unloaded or Bad records into different table.
    do we have any attributes in sqlldr to accomplish this?
    Regards
    Bala.

    Bala,
    You can load bad file (rejected records) in different table with all the column defined as varchar2 using sqlldr or external table. But you have to defined another table with all the columns as varchar2 and load it up using a different sqlldr control file, you can also consider using external table to load bad file (bad records).
    Regards

Maybe you are looking for