Sie können union
verwenden Städtetabelle zu erstellen und dann minus
Betreiber.
select 'Dallas' as city from dual union all
select 'Berlin' as city from dual union all
select 'Cracow' as city from dual union all
select 'Praha' as city from dual
minus
select city from address
Anstelle von Union können Sie den vordefinierten Typ odcivarchar2list
verwenden , was die Syntax verkürzt:
select column_value as city
from table(sys.odcivarchar2list('Dallas', 'Berlin', 'Cracow', 'Praha'))
minus
select city from address
... und statt minus
Sie können Joins oder not in
verwenden oder not exists
.
Testdaten und Ausgabe beider Abfragen:
create table address (id number, city varchar2(10));
insert into address values (1, 'Rome');
insert into address values (2, 'Dallas');
insert into address values (3, 'Cracow');
insert into address values (4, 'Moscow');
insert into address values (5, 'Liverpool');
insert into address values (6, 'Cracow');
insert into address values (7, 'Seoul');
CITY
------------
Berlin
Praha