select objectid
,name
,address
from library_t l
where not exists (select *
from d107 d
where l.objectid = d.objectid
)
select objectid
,name
,address
from library_t l
where l.objectid not in (select objectid
from d107
)
If both objectid columns have indexs, which one is better in oracle?
Use
NOT EXISTS.The execution plans may be the same at the moment but if either column is altered in the future to allow NULLs the NOT IN version will need to do more work.
The most important thing to note about NOT EXISTS and NOT IN is that, unlike EXISTS and IN, they are not equivalent in all cases. Specifically, when NULLs are involved they will return different results. To be totally specific, when the subquery returns even one null, NOT IN will not match any rows.