集合操作minus,在sql中是经常用到的,这也是作为dba必须掌握的.
下面是minus用法示例:
[@more@]create table t (a number,b number,c number);
create table t1 (a number,b number,c number);
insert into t values(1,2,3);
insert into t values(4,5,6);
insert into t values(10,11,12);
insert into t1 values(1,2,3);
insert into t1 values(7,8,9);
insert into t1 values(13,14,15);
commit;
select * from t;
a b c
1 2 3
4 5 6
10 11 12
select * from t1;
a b c
1 2 3
7 8 9
13 14 15
t minus t1
select * from t
minus
select * from t1;
a b c
4 5 6
10 11 12
t1 minus t
select * from t1
minus
select * from t;
a b c
7 8 9
13 14 15
上面的例子,你看出了minus的用法没有?如果没有,我来分析一下:
t minus t1 ,表示t 减 t1 ,得到的结果集是:去掉t表与t1相同的,即1,2,3,再去掉t1表的其他内容,即7,8,9与13,14,15。得到的结果集就是4,5,6与10,11,12。
t1 minus t ,表示t1 减 t ,得到的结果集是:去掉t1表与t相同的,即1,2,3,再去掉t表的其他内容,即4,5,6与10,11,12。得到的结果集就是7,8,9与13,14,15。
这就是minus的使用方法,希望你能掌握它。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28227905/viewspace-1060243/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28227905/viewspace-1060243/