Search notes:

Oracle SQL Plan operation MINUS

The plan operation MINUS has two child row-sources of which the first typically is a SORT UNIQUE and the second a SORT UNIQUE or a TABLE ACCESS BY INDEX ROWID BATCHED (but I've seen other operations also).
create table tq84_X (txt varchar2(10));
create table tq84_Y (txt varchar2(10));

begin
insert into tq84_X values ('three');
insert into tq84_X values ('two'  );
insert into tq84_X values ('three');
insert into tq84_X values ('two'  );
insert into tq84_X values ('one'  );

insert into tq84_Y values ('two'  );
insert into tq84_Y values ('xxx'  );
insert into tq84_Y values ( null  );
end;
/

explain plan for
select txt from tq84_X minus
select txt from tq84_Y;

select * from table(dbms_xplan.display(format=>'basic'));
--
-- --------------------------------------
-- | Id  | Operation           | Name   |
-- --------------------------------------
-- |   0 | SELECT STATEMENT    |        |
-- |   1 |  MINUS              |        |
-- |   2 |   SORT UNIQUE       |        |
-- |   3 |    TABLE ACCESS FULL| TQ84_X |
-- |   4 |   SORT UNIQUE       |        |
-- |   5 |    TABLE ACCESS FULL| TQ84_Y |
-- --------------------------------------


drop table tq84_X;
drop table tq84_Y;

See also

The SQL set operator minus.
Plan operations

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740463186, '3.145.90.244', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQL/statement/execution/plan/operations/minus/index(77): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78