What is the difference between the two update statements

Hi Everyone
Along with the emp table in scott kindly insert the to ins statement into emp.
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
Values
(8000, 'JAMES', 'CLERK', 7698, sysdate,
1000, 10, 30);
Insert into EMP
(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
Values
(8001, 'JAMES', 'CLERK', 7698, sysdate,
1000, 10, 30);
Consider the below two update statements.
1) update emp a
set ename=(select loc
from dept b
where a.deptno=b.deptno)
where exists(select loc
from dept b
where a.deptno=b.deptno)
2) update emp a
set ename=(select loc
from dept b
where a.deptno=b.deptno)
What is the difference between the 1st and 2nd update statement? what is the use of exists clause in the first update statement ? Can u suggest in what case will the two update statements provide different results.
Thanks in advance

Second one updates all records in emp. If there is no record in dept then ename will be updated to null.
The first one only updates records in emp where a record in dept exists. It does not matter whether loc is non-null in dept or not. In an EXISTS query it doesn't matter if you do SELECT *, SELECT LOC, SELECT 1, SELECT NULL - Oracle just checks for existence.
So most often an update like the first one is meant to improve performance by only updating those emp records that are needed. Usually that is a good idea.
For this very specific case where all employees do belong to a department, all records in emp will be updated anyway, so for this specific case it actually makes worse performance because it does work to make an unnecessary check.
Normally the EXISTS query is good for performance, but always figure out if they are needed first ;-)

Similar Messages

  • What are the differences between the Caching and the Software Update Services

    New to working with OS X Server and am confused about the differences between the Caching Service and the Software Update Service...it seems to me that they overlap in that i) the Caching Service updates OS X software, iOS software and any apps purchased from the app store while ii) the Software Update service updates OS X software.
    If the above is correct they why would one run both Services?  I would think that one would run the Caching Service and call it a day!
    And while on the subject, what about caching and pushing third party apps like MS Office?

    Linc Davis wrote:
    The simple answer is that you almost certainly don't need the Software Update service. Just use the Caching service. Neither one works with content that doesn't come from Apple.
    Appreciate the response but could you please explain the difference between the two as that is the one item that remains unanswered.
    Thanks,
    Joel

  • Whats the difference between the combo update vs. standard update?

    I'm curious to know which update to use. So what is the difference between the two?
    Thank you

    The standard (called a 'delta' update) can be applied to one version back, e.g. the 10.5.7 delta update works only if you are running 10.5.6. The combo update will update from any previous version of the main OS release, e.g. the 10.5.7 combo update works if you are running 10.5.0 through 10.5.6 (but not, for example, 10.4.11).
    The combo update can also be reapplied as a troubleshooting step (i.e. if you are having problems with 10.5.7, you can download and run the 10.5.7 combo updater).
    If you use Software Update, it will apply the appropriate update (the delta if you are running the immediately previous version, the combo if you are >1 version back).

  • What is the difference between qued delta  update and serialized delta upda

    what is the difference between qued delta  update and serialized delta update?

    Hi Ks Reddy,
    Queued Delta:
    In case of Queued delta LUW's are posted to Extractor Queue (LBWQ), by scheduling the V3 job we move the documents from Extractor queue to Delta Queue(i.e. RSA7) and we extract the LUW's from Delta Queue to BW side by running Delta Loads. Generally we prefer Queued Delta as it maintain the Extractor Log which us to handle the LUW's which are missed.
    Direct Delta:
    In case of Direct Delta LUW's are directly posted to Delta Queue(i.e. RSA7) and we extract the LUW's from Delta Queue to BW side by running Delta Loads. If we use Direct Delta it degrades the OLTP system performance because when LUW's are directly posted to Delta Queue (RSA7) the application is kept waiting untill all the enhancement code is executed.
    Non-serialized V3 Update:With this update mode, the extraction data for the application considered is written as before into the update tables with the help of a V3 update module. They are kept there as long as the data is selected through an updating collective run and are processed. However, in contrast to the current default settings (serialized V3 update), the data in the updating collective run are thereby read without regard to sequence from the update tables and are transferred to the BW delta queue.
    https://websmp102.sap-ag.de/~sapdownload/011000358700007535452002E/HOWTOCREATEGENERICDELTA.PDF (need id)
    http://help.sap.com/saphelp_bw33/helpdata/en/3f/548c9ec754ee4d90188a4f108e0121/frameset.htm
    Business Intelligence Performance Tuning [original link is broken]
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    How to load data
    /people/sap.user72/blog/2004/12/16/logistic-cockpit-delta-mechanism--episode-one-v3-update-the-145serializer146
    /people/sap.user72/blog/2004/12/23/logistic-cockpit-delta-mechanism--episode-two-v3-update-when-some-problems-can-occur
    /people/sap.user72/blog/2005/01/19/logistic-cockpit-delta-mechanism--episode-three-the-new-update-methods
    Delta Types and methods;�
    Hope this helps.
    ****Assign Points if Helpful*****
    Regards,
    Ravikanth

  • Whats the difference between these two queries ? - for tuning purpose

    Whats the difference between these two queries ?
    I have huge amount of data for each table. its takeing such a long time (>5-6hrs).
    here whice one is fast / do we have any other option there apart from listed here....
    QUERY 1: 
      SELECT  --<< USING INDEX >>
          field1, field2, field3, sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end)
        FROM
          tab1 inner join tab2 on condition1 inner join tab3 on condition2 inner join tab4 on conditon3
        WHERE
         condition4..10 and
        GROUP BY
          field1, field2,field3
        HAVING
          sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end) <> 0;
    QUERY 2:
       SELECT  --<< USING INDEX >>
          field1, field2, field3, sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0))
        FROM
          tab1, tab2, tab3, tab4
        WHERE
         condition1 and
         condition2 and
         condition3 and
         condition4..10
        GROUP BY
          field1, field2,field3
        HAVING
          sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0)) <> 0;
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    My feeling here is that simply changing join syntax and case vs decode issues is not going to give any significant improvement in performance, and as Tubby points out, there is not a lot to go on. I think you are going to have to investigate things along the line of parallel query and index vs full table scans as well any number of performance tuning methods before you will see any significant gains. I would start with the Performance Manual as a start and then follow that up with the hard yards of query plans and stats.
    Alternatively, you could just set the gofast parameter to TRUE and everything will be all right.
    Andre

  • What is the difference between these two reports MC.1 and MB5L

    Hi
    what is the difference between these two reports MC.1 and MB5L?
    what is the Purpose of each report?
    Material ledger is activated for this plant, we found some amount difference between these two reports, my client accounting department used to compare these two reports while year end/month end closing
    Thanks
    Raju

    MC.1 will give you the report for plant analysis as per plant .
    MB5L report will give you list of stock value as per G/L account wise.

  • In jdbc adapter what is the difference between insert and update insert

    in jdbc adapter what is the difference between insert and update insert
    Edited by: katru vijay on Mar 22, 2010 7:43 AM

    Please refer to this Link [Document Formats for the Receiver JDBC Adapter|http://help.sap.com/saphelp_nw04/Helpdata/EN/22/b4d13b633f7748b4d34f3191529946/frameset.htm]
    Hope this helps.
    Regards,
    Chandravadan

  • What's the difference between these two backup systems?

    When I bought my Macbook Pro I bought a Seagate external HD that used Bounceback Express as its backup application. But now my Mac defaults to Time Machine. What's the difference between the two applications? When I use Time Machine to back up my hard drive to the Seagate external, is it doing the same thing as Bounceback Express used to?

    In analog terms, to explain YCbCr use the example of the COMPONENT output from your DVD player. It use 3 separate cables (Y = Luminance = Green Cable), (Y-B = Blue Color Diff = BLUE Cable) and (Y-R = Red Color Diff = RED Cable). In the analog world, RGB is actually RGBHV (5-wire) and is adaptable to 15-pin VGA with a simple passive adapter. Many people will mistakenly refer to Analog Component video as RGB, since the cables are Red, Green and Blue.
    So, since all that mumbo jumbo means essentially the same, this appears to be the digital "equivalent" of what is known as Component Video in the Analog world... What I said about RGBHV does not apply to the 10-bit color, but thought I'd mention it anyway.
    -BChil

  • What are the differences between this two statements???

    1.select * from counter where eboxid = (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    2.select b.* from zsyy_ocecs.CM_SUBS_SUBSCRIBER a,COUNTER b where a.acctid = b.eboxid and a.servnumber = ?;
    what are the differences between the 2 sql statements??
    I WILL APPRECIATE FOR YOUR ANSWERS VERY MUCH, BECAUSE I WAS PUZZLED WHEN I SAW THE EXECUTION PLANS.THANKS AGAIN. MR SHI.
    the followings are their execute plans:
    Command> select * from counter where eboxid = (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    Query Optimizer Plan:
    STEP: 1
    LEVEL: 2
    OPERATION: TblLkTtreeScan
    TBLNAME: ZSYY_OCECS.CM_SUBS_SUBSCRIBER
    IXNAME: IDX_SERVNUM
    INDEXED CONDITION: CM_SUBS_SUBSCRIBER.SERVNUMBER = qmark_1
    NOT INDEXED: ROWNUM < 3
    STEP: 2
    LEVEL: 2
    OPERATION: RowLkTtreeScan
    TBLNAME: COUNTER
    IXNAME: IDX_COUNTER
    INDEXED CONDITION:
    COUNTER.EBOXID = CM_SUBS_SUBSCRIBER.ACCTID
    NOT INDEXED: <NULL>
    STEP: 3
    LEVEL: 1
    OPERATION: NestedLoop
    TBLNAME: <NULL>
    IXNAME: <NULL>
    INDEXED CONDITION: <NULL>
    NOT INDEXED: <NULL>
    Command> select b.* from zsyy_ocecs.CM_SUBS_SUBSCRIBER a,COUNTER b where a.acctid = b.eboxid and a.servnumber = ?;
    Query Optimizer Plan:
    STEP: 1
    LEVEL: 2
    OPERATION: TmpTtreeScan
    TBLNAME: ZSYY_OCECS.CM_SUBS_SUBSCRIBER
    IXNAME: <NULL>
    INDEXED CONDITION: <NULL>
    NOT INDEXED: A.SERVNUMBER = qmark_1
    STEP: 2
    LEVEL: 2
    OPERATION: TblLkTtreeScan
    TBLNAME: COUNTER
    IXNAME: IDX_COUNTER
    INDEXED CONDITION: B.EBOXID
    = A.ACCTIDNOT INDEXED: <NULL>
    STEP: 3
    LEVEL: 1
    OPERATION: MergeJoin
    TBLNAME: <NULL>
    IXNAME: <NULL>
    INDEXED CONDITION: A.ACCTID = B.EBOXID
    NOT INDEXED: <NULL>
    Edited by: user9533799 on 2008-9-3 上午1:28

    If zsyy_ocecs.cm_subs_subscriber table returns one row for each servnumber, both statements would return the same data. But if there was a servnumber value on two rows, the first statement will throw an error (you a comparing a value with a set of values). You can rewrite the first query to avoid this:
    select * from counter where eboxid in (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    Conceptually they are different and the execution plan can't be the same.

  • What's the difference between the two Library folders?

    What's the difference between the two Library folders - the one in the users folder and the other?

    /Library contains files and settings that apply system wide to all users.
    ~/Library contains files and settings that only apply to your user account.

  • What is the difference between these two sticks of RAM?

    I am upgrading my Macbook 2.2 GHz Intel Core 2 duo from 2GB of ram to 4GB
    What is the difference between these two kits?
    4GB Kit (2 x 2GB) 200 Pin DDR2-667 PC2-5300 256x64 CL5 1.8V SODIMM ($102.00)
    4GB Kit (2 x 2GB) eRam 200 Pin DDR2-667 PC2-5300 CL5 1.8V SODIMM ($88.00)

    Probably nothing of any consequence. Some places can just negotiate better deals with suppliers. Or one of a million other factors that can affect price is in play here.
    When buying RAM, I generally find it's better to pay a little extra to get a brand that's known for quality. I usually stick to Crucial myself. If you look around, you can probably find some real steals out there, but I don't know... With stories of people who literally go dumpster diving, salvaging stuff that was slated for disposal, then turning around and selling it... I prefer not to take chances. If you are, by all means, go for the cheaper one.

  • What is the difference between these two portalapps folders on the Server?

    Hello,
    On the Server there are two portalapps folder:
    1. Under: C:\usr\sap\JXX\JC00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\portalapps
    2. Under: C:\usr\sap\JXX\JC00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\portalapps
    Can someone please explain me what is the difference between these two portalapps folders and under which case will I turn to which folder?

    Hi Roy,
    The one at this location
    Under: C:\usr\sap\JXX\JC00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\portalapps
    has all the files from the WEB-INF folder i.e. these are the non-web resources and cannot be accessed via HTTP(S) examples would be imgaes, CSS etc that you want only your application to access
    those under
    Under: C:\usr\sap\JXX\JC00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\portalapps
    they have all the .JAR files, portalapp.xml, config properties etc. these are web resources and can be accessed via HTTP(S)
    Hope this is of help.
    Akhilesh

  • What is the difference between these two commands?

    What is the difference between these two commands?
    DROP TABLESPACE users INCLUDING CONTENTS;
    DROP TABLESPACE users INCLUDING CONTENTS AND DATAFILES;
    --------No.202

    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9004.htm#i2133717

  • What's the difference between the two Hanging Tree songs on iTunes?

    What's the difference between the two Hanging Tree songs on iTunes?

    /Library contains files and settings that apply system wide to all users.
    ~/Library contains files and settings that only apply to your user account.

  • What's the difference between the two IE11 installers listed below?

    Hello,
    What is the difference between these two IE-11 downloads (image below)? One is 28MB and one is 54MB. I am having a lot of post-installation issues with the 54MB installer (i.e. opens blank pages, can't access a simple page like google, Windows search stops
    indexing). When I install the 28MB download, (so far) I don't have any issues. Since the 28MB installation works, it sounds like my desision is easy but I would still like to know the difference between the two. BTW, the quick install is only 2MB, so I know
    I don't have the quick install. 
    Any help would be appriciated, thank you in advance.
    Sorry, for the spacing on the links below. This system won't let me add 'real' links until my account is varified.
    28MB Installer Link
     microsoft . com / en-us / download / details.aspx?id=40902
    54MB Installer Link
     windows . microsoft . com / en-us / internet-explorer / ie-11-worldwide-languages

    Hi,
    In my environment, they are the same size:
    Alex Zhao
    TechNet Community Support

Maybe you are looking for