新建兩個表:
create table guotest1
(
sname varchar2(10),
gender varchar2(10)
)
create table guotest2
(
sname varchar2(10),
gender varchar2(10)
)
插入數(shù)據(jù):
insert into guotest1 values('a', 'm');
insert into guotest1 values('b', 'm');
insert into guotest1 values('c', 'f');
insert into guotest1 values('d', 'f');
insert into guotest2 values('e', 'm');
insert into guotest2 values('f', 'm');
insert into guotest2 values('g', 'f');
insert into guotest2 values('h', 'f');
1 minus返回的是兩個查詢結(jié)果表的差集
例如:select * from guotest1 where rownum <= 4 minus select * from guotest1 where rownum <= 2
返回結(jié)果:
sname,gender
c,f
d,f
2 minus返回的記錄總是來自于左邊的表
例如:select * from guotest1 minus select * from guotest2
返回結(jié)果:
sname,gender
a,m
b,m
c,f
d,f
像是說:如果左邊的表中的某個記錄存在于右邊的表中,則該記錄不會返回
更多信息請查看IT技術(shù)專欄