首页 > 网站 > 建站经验 > 正文

Orac!le minus使用

2019-11-02 14:36:51
字体:
来源:转载
供稿:网友

   新建两个表:

  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(

颓废网名[www.la240.com/html2017/1/30/]
'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 <= 4 minus select * from guotest1 where rownum <= 2

  返回结果:

  "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"

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表