在Oracle中,可以使用以下幾種方式來查詢兩個表不同的數據:
SELECT column1, column2, ...
FROM table1
MINUS
SELECT column1, column2, ...
FROM table2;
SELECT column1, column2, ...
FROM table1
WHERE (column1, column2, ...) NOT IN
(SELECT column1, column2, ...
FROM table2);
SELECT column1, column2, ...
FROM table1
WHERE NOT EXISTS
(SELECT column1, column2, ...
FROM table2
WHERE table1.column1 = table2.column1
AND table1.column2 = table2.column2
...);
SELECT table1.column1, table1.column2, ...
FROM table1
LEFT JOIN table2 ON table1.column1 = table2.column1
AND table1.column2 = table2.column2
...
WHERE table2.column1 IS NULL
AND table2.column2 IS NULL
...;
以上方法都可以用來查詢在table1中存在但在table2中不存在的數據。如果要查詢在table2中存在但在table1中不存在的數據,只需要交換table1和table2的位置即可。