Oracle 11g中的EXCEPTION JOIN

时间:2015-05-18 22:51:42

标签: oracle oracle11g

在我作为DB2开发人员从几十年转变为现在的Oracle开发人员的过程中,我对某些Oracle语法存在一些问题。

我在线看到的Oracle文档似乎表示Oracle支持EXCEPTION JOIN,但是当我尝试在Oracle 11g中使用它时,它会失败。我错过了什么?

select t1.*
  from MySchema.TestingStuff_Table1 t1
;

     THEPK FIRSTNAME          
---------- --------------------
         1 Fred                 
         2 Wilma                
         3 Barney               
         4 Betty                

select t2.*
  from MySchema.TestingStuff_ExcludeThese t2
;

     THEPK
----------
         1 

select t1.*
  from MySchema.TestingStuff_Table1 t1
 where not exists (
   select *
     from MySchema.testingstuff_ExcludeThese t2
    where t2.thepk = t1.thepk
)
;

     THEPK FIRSTNAME          
---------- --------------------
         2 Wilma                
         3 Barney               
         4 Betty                

select t1.* 
  from MySchema.TestingStuff_Table1 t1
  exception join MySchema.TestingStuff_ExcludeThese t2
    on t2.thePK = t1.thePK
;

Error at Command Line:3 Column:3
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"

感谢您的帮助! DaveSlash

1 个答案:

答案 0 :(得分:-1)

似乎有别名问题。这将有效:

select MySchema.TestingStuff_Table1.*
from MySchema.TestingStuff_Table1 
exception join MySchema.TestingStuff_ExcludeThese 
on TestingStuff_ExcludeThese.thePK = TestingStuff_Table1.thePK
;