Why this two queries are not same

Hi all

Can you please explain this fundamental thing. Why this two queries are different. (10.2.0.3 Solaris Sparc 64)
create table x1(a1 varchar2(10),a2 number, a3 varchar2(10));
create table x2(b1 varchar2(10),b2 number, b3 varchar2(10));
insert into x1 values('X101',1,'XX1');
insert into x1 values('X101',1,'XX1');
insert into x1 values('X102',1,'XX2');
insert into x1 values('X103',2,'XX3');
insert into x1 values('X104',2,'XX4');
insert into x1 values('X105',3,'XX5');
commit;

insert into x2 values('X101',1,'X21');
insert into x2 values('X101',1,'X21');
insert into x2 values('X102',1,'X22');
insert into x2 values('X103',2,'X23');
insert into x2 values('X104',2,'X24');
commit;

WITH xx AS (select b1,b2 from x2 where b1 IS NULL)
 select x1.* from x1 ,  xx
  where x1.a1 = xx.b1(+) and  x1.a2 = xx.b2(+) ;
 
A1                 A2 A3
---------- ---------- ----------
X105                3 XX5
X104                2 XX4
X102                1 XX2
X103                2 XX3
X101                1 XX1
X101                1 XX1
 
6 rows selected
 
select x1.* from x1, x2 where x1.a1 = x2.b1(+)
    and x1.a2 = x2.b2(+)  and x2.b1 IS NULL;
 
A1                 A2 A3
---------- ---------- ----------
X105                3 XX5
 
select b1,b2 from x2 where b1 IS NULL;
 
B1                 B2
---------- ----------
 

Thank you!
NA not (sentence of) think of this.
+ (it's one of those things that I really need of don't forget do not forget ;)) +)

hoek&XE> select x1.*
  2  from   x1
  3  where not exists ( select null
  4                     from   x2
  5                     where  x1.a1 = x2.b1
  6                     and    x1.a2 = x2.b2
  7                    );

A1                 A2 A3
---------- ---------- ----------
X105                3 XX5

1 rij is geselecteerd.

Uitvoeringspan
----------------------------------------------------------
Plan hash value: 816925353

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     5 |   100 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN ANTI    |      |     5 |   100 |     5  (20)| 00:00:01 |
|   2 |   TABLE ACCESS FULL| X1   |     6 |    72 |     2   (0)| 00:00:01 |
|   3 |   TABLE ACCESS FULL| X2   |     5 |    40 |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("X1"."A1"="X2"."B1" AND "X1"."A2"="X2"."B2")

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          6  consistent gets
          0  physical reads
          0  redo size
        518  bytes sent via SQL*Net to client
        384  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

Tags: Database

Similar Questions

  • Why this message: you are not allowed to view or update this topic

    Why this message: you are not allowed to publish or comment on it.

    It's a legitimate question.

    You encounter a bug in the Jive Software that runs this forum. Most of the time simply try again or refresh the page will fix the problem. There is one caveat with respect to time. You can't post more than once every 30 seconds, and it's to discourage spamming.

  • "Why the 2 screws are not same speed?

    HI comrades LabVIEW in love.

    Could someone let me know why the 2 screws attached do not run at the same speed I expect?

    Thanks in advance.

    Bryan

    Inside the event, value is only designed for the value of signalling events on the time-out, i.e. every 100 ms.

    Outside of the event is happening at the same time, so he writes to each iteration of the loop, and the timeout never occurs.

  • Why the out put of the queries are not compatible?

    Why the out put of the queries are not compatible for the same object?
    -----------------------------------------------------------------------------

    SQL > select table_name, blocks from user_tables where table_name = 'ENTRANTS ';

    TABLE_NAME BLOCKS
    ------------------------------ ----------
    ENTRANTS * 0 *.

    ---------------------------------------------------------------------------

    SQL > select count (*) in incoming.

    COUNT (*)
    ----------
    * 200000 *.

    Beacause after insertion of 200000 enties, table user_table not but I have statistics and statistical data not updated before you query the user_table. Use analyze, command to get new statistics for this table.

  • How I would compare if two indexes are the same?

    I like to compare if two indexes of two users are the same. Is it possible to to that. I need similer to query below:

    to select (2 * (select count (*) from (select * of XPKTBL_A CROSS, select * from XPKTBL_A)) - (select count (*) in XPKTBL_A) - (select count (*) in XPKTBL_A)) WHEN 0 THEN "Index are the same" ELSE 'Indices are different' END 'Result' from DUAL;

    UserA:

    create table TBL_A (FIELD_A1 number not null,

    FIELD_A2 varchar2 (50).

    Date of FIELD_A3,

    FIELD_A4 number (5.2) default 0,

    FIELD_A5 varchar2 (10) not null

    );

    create a unique index XPKTBL_A on TBL_A (FIELD_A1);

    UserB:

    create table TBL_A (FIELD_A1 number not null,

    FIELD_A2 varchar2 (20).

    FIELD_A4 number (5.2) not null,

    FIELD_A5 varchar2 (10),

    FIELD_A6 number (2) not null

    );

    create a unique index XPKTBL_A on TBL_A (FIELD_A1, FIELD_A6);

    Thanks for the reply Lalit and sorry for the late reply... I got my answer already.

  • The input and output encodings are not same

    Hello

    I'm trying to quantify a value by using the function 'Encrypt' and the same thing I'm trying to decipher in the next page before you update the database.

    I am using the same key algorithm and the encoding process to decrypt.

    But he is back this error "input and output encodings are not same.

    Can someone help me on this?


    form.txtPassword is plain text.  You can't decrypt() plain text.

    --

    Adam

  • How do I know if the two tables are the same in the data they contain

    Hello

    How will I know if the two tables are the same in the data they contain?

    Hello

    Please check this thread [compare all columns | http://forums.oracle.com/forums/thread.jspa?messageID=3166309�].

    Kind regards

  • When the progressions referred to my Office I get two icons, one is a file folder, when I try to delete this two icons are removed

    When the progressions referred to my Office I get two icons, one is a file folder, when I try to delete this two icons are removed from the trash how to solve?

    When the progressions referred to my Office I get two icons, one is a file folder, when I try to delete this two icons are removed from the trash how to solve?

    So if you right-click on the desktop and choose New--> shortcut and then create a shortcut to something, what is happening?

  • When using adjustment layers, I get the message "adobe could not rasterize because pixels for this layer data are not directly editable" what's the problem?

    When using adjustment layers, I get the message "adobe could not rasterize because pixels for this layer data are not directly editable" what's the problem?

    This happens because there is no mask on adjustment and you have selected the Brush tool. You cannot paint on an adjustment. If the masks are not be created by default when you create the adjustment and you want that they be created, select mask add default option in the context menu of adjustments of the

  • How to find the data in two tables are the same?

    Hi people,

    Suppose we have table emp01, have 10 records and create another emp02 as table

    create the table emp02 in select * from emp01;

    now both the table has the same data.

    How to find a 'data' in the two tables are the same?

    Hello

    SELECT *
    FROM emp01
    MINUS
    SELECT *
    FROM emp02
    UNION
    SELECT *
    FROM emp02
    MINUS
    SELECT *
    FROM emp01
    

    You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.

    Best regards
    Nikolai

  • Why the proxy settings are not respected

    I set up SSH as a proxy server on my laptop when I'm on a public network and configure Firefox to use the proxy by completing the manual Proxy config.

    If SSH doesn't work, I get this error message as expected: "the proxy server refuses connections" when I try to access any website EXCEPT Google.

    Searches on Google and access Google.com still works, even when the proxy server is not up. That seems broken.

    When the proxy server IS up, Google searches do not appear to use it.

    Google is my default search provider. If I try to access Bing, Firefox is behaving as expected (no access when proxy is out, throw up debugging indicating new connections when the proxy is up). If I change from Bing to be default search provider, the behavior of the two remains the same (proxy will use Bing, Google does not work).

    Why access to Google (and only Google?) ignore the proxy settings? Are there other sites of 'magic' that would also ignore the proxy? I use the proxy because I want to protect my internet traffic when I'm on public networks, if Firefox can randomly ignore them for some sites but not others, how can I trust him?

    My configuration problem. I realized that any site that uses https worked, while others are not.

    Somehow the "use this proxy server for all protocols" got unchecked. Audit, it solves the problem.

  • Why this CASE statement would not work?

    If I use a CASE in my SELECT statement and met a strange thing and just need help to understand why he did it.

    When I type this, it does not work:

    CASE TRIM (Column1)
    WHEN NULL THEN Column2
    WHEN 'foo' THEN Column2
    Of ANOTHER Column1
    END AS NewColName

    I use this query in an Oracle procedure to insert data into another table. The data inserted in the column of NewColName end up being 4 empty spaces, located in Column1. In the logic of this, TRIM must remove all the empty spaces, and he should get mapped to the first statement WHEN, who must insert the value of Column2, but that does not occur. I tried the following versions of the first line as well:

    LTRIM (RTRIM (Column1)) CASE
    CASE of REPLACE (Column1, ' ', ")

    and they all produce the same result. I also tried to change WHEN NULL for WHEN " and it changed nothing. However, when I rewrite the statement in this way it works the way it should:

    CASE
    WHEN TRIM (Column1) IS NULL, Column2
    WHEN TRIM (Column1) = 'foo' THEN Column2
    Of ANOTHER Column1
    END AS NewColName

    In my mind, it seems that these two methods are trying the same thing, why we could work and the other not? Only, it has no sense to me.

    Thank you

    Hello

    Welcome to the forum.

    In your first statement, you have

    WHEN NULL THEN.

    This is the same as x = NULL.

    Nothing is never equal to NULL, if you find yourself in your ELSE clause.

    Concerning
    Peter

  • Help - why the songs that are not on my iPhone appearing in my list of app music albums/songs?

    I have over 500 GB of music on my Mac, so I create a playlist for the songs I want to sync my iPhone. Yet when I look at my phone, there are many songs that are not in sync would be playlist. They cannot be read unless the phone is connected to my wifi at home, but I don't want them cluttering up my phone and makes it almost impossible to find the tracks I want to listen to.

    I hate the new music app. For the first time since I converted to Apple 10 years ago, I wonder if I can be forced away because it's so horrible. Why ruin a great product with terrible software? Anyway, if anyone can help me to fix this serious bug, I would be very grateful.

    If you go to the library of the screen and press the red text just below the icons of the album/playlist (where you select whether you want the screen to show the view of the artist/Album/songs downstairs there is a toggle to only show that downloaded music.) If you enable this, then only the songs that are actually ON your iPhone will be in BLACK characters. The rest of your music library to iCloud either won't display at all or be grey. Now - if you have a few streaming, you can see more songs, because the songs that are heard are cached in the memory of the iPhone box and supposedly deleted automatically when it fills up (but not user accessible unless you use some third-party programs).

    What you can do - so they need WiFi or data cell-, it's make a playlist in iTunes that you want on your iPhone. Then (assuming that Apple music and iCloud music library are running on both), you can go to the playlist and press the small cloud/down arrow icon and download these tracks on your iPhone. Then, you can play these songs without access to wifi or cell phone.

  • Why this SQL statement is not recovering this indicator of index?

    Hello

    We use Oracle 10.2.0.4.

    I'm trying to understand why the following query will not use the index indicator. Anyone know? This is an index of compost.
    select   
    /*+ INDEX(pa_cost_distribution_lines_all pa_cost_distribution_lines_n5) */ 
    system_reference2, system_reference3 , system_reference1,
     EXPENDITURE_ITEM_ID 
    from pa_cost_distribution_lines_all
    where 
    --eXPENDITURE_ITEM_ID = 734145
     system_reference2=407530
    and  system_reference3 = 1
    and  system_reference1 = 669014
    Here is the plan of the explain command.
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 20,326  Bytes: 13  Cardinality: 1       
         1 TABLE ACCESS FULL TABLE PA.PA_COST_DISTRIBUTION_LINES_ALL Cost: 20,326  Bytes: 13  Cardinality: 1  
    Here's the script for the index.
    CREATE INDEX PA_COST_DISTRIBUTION_LINES_N5 ON PA_COST_DISTRIBUTION_LINES_ALL
    (SYSTEM_REFERENCE2, SYSTEM_REFERENCE3, SYSTEM_REFERENCE1)
    LOGGING
    TABLESPACE APPS_TS_TX_IDX
    PCTFREE    5
    INITRANS   11
    MAXTRANS   255
    STORAGE    (
                INITIAL          128K
                NEXT             128K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
               )
    NOPARALLEL;
    Thank you.

    SYSTEM_REFERENCE1/2/3 are VARCHAR2 columns.

    Oracle is to resolve the query by using an implicit "TO_NUMBER" on each column, which makes the path of the index not available, you can check it out using SET AUTOTRACE ON and observing:

    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter(TO_NUMBER("SYSTEM_REFERENCE2")=407530 AND
                  TO_NUMBER("SYSTEM_REFERENCE1")=669014 AND TO_NUMBER("SYSTEM_REFERENCE3")=1)
    

    If you explicitly put quotes or "TO_CHAR" around the values then the index will be used. For example:

    select
    /*+ INDEX(pa_cost_distribution_lines_all pa_cost_distribution_lines_n5) */
    system_reference2, system_reference3 , system_reference1,
     EXPENDITURE_ITEM_ID
    from pa_cost_distribution_lines_all
    where
    --eXPENDITURE_ITEM_ID = 734145
     system_reference2='407530'
    and  system_reference3 = '1'
    and  system_reference1 = '669014'
    /
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("SYSTEM_REFERENCE2"='407530' AND "SYSTEM_REFERENCE3"='1' AND
                  "SYSTEM_REFERENCE1"='669014')
    
  • Why the acquired data are not from min to max (DAQmxCreateAIVoltageChan, PXI-4472) values

    Hello

    I'm developing a program for the PXI-4472 acquisition on opensuse 11.4 device (linux 2.6.34).

    I try to acquire analog data and to read in a wav file.

    Configure the task of acquisition with the following functions:

    DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","OnboardClock",DAQmx_Val_Cfg_Default,-10.0f,10.0f,DAQmx_Val_Volts,NULL);
    DAQmxCfgSampClkTiming(taskHandle,"",48000,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,48000);

    DAQmxDisableStartTrig (taskHandle);

    I don't understand why the data stored in the wav file are not-10V,-10V but-5V, 5V... (the value of the gain is 0dB). (Perhaps a scale of 0.5?...)

    Thanks for your help,

    Amandine

    You're right, in my example, I considered as unsigned data.

    Concerning

Maybe you are looking for

  • Faces random restart disaster photos

    For nearly a decade, we have used our iPhoto as screen saver library on our iMac 2008 and identified thousands of faces among our 20 K photos. A month ago, we bought a replacement iMac and Apple just told me to throw all this time spent ID'ing faces

  • Re: Resize Partitions on Satellite L670-12J

    Purpose:Having a single 500 GB partition for the system and data. Current situation:Partition 1 - 232 GB systemPartition the HARD drive recovery data contains - Data 232 GB - 2 What I've done so far:I created 3 DVD of the recovery partition recovery

  • Restore backup files

    On my old computer, I had to restore XP to factory because of problems with system settings. The option I have chosen has allowed me to save my files and I can see the lists of directories and files in the folder "My Backup", but could not find the f

  • Receive the message 'the required in the INF section' what install Epson SX115

    I try to install my epson SX115 but the scanner will not install the drivers I just get "section in the inf file" Please help

  • Activation of MS Outlook - why not - he accepts my paid for the code?

    I installed MS Outlook and bought an activation code for Outlook from Microsoft online, but when it asks me to enter the activation code provided, he tells me is not valid and the software either cut mode which is pretty useless. How can I activate t