欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle minus使用

程序员文章站 2022-04-27 17:01:02
...

新建两个表: create table guotest1 ( sName varchar2(10), Gender varchar2(10) ) create table guotest2 ( sName varchar2(10), Gender varchar2(10) ) 插入数据: insert into guotest1 values('a', 'm'); insert into guotest1 values('b', 'm'); inser

  新建两个表:

  create table guotest1

  (

  sName varchar2(10),

  Gender varchar2(10)

  )

  create table guotest2

  (

  sName varchar2(10),

  Gender varchar2(10)

  )

  插入数据:

  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返回的是两个查询结果表的差集

  例如:select * from guotest1 where rownum

  返回结果:

  "SNAME","GENDER"

  "c","f"

  "d","f"

  2 minus返回的记录总是来自于左边的表

  例如:select * from guotest1 minus select * from guotest2

  返回结果:

  "SNAME","GENDER"

  "a","m"

  "b","m"

  "c","f"

  "d","f"

  像是说:如果左边的表中的某个记录存在于右边的表中,,则该记录不会返回