1,UNION对数据进行排序,并压缩重复数据;
SQL> select * from test3;
ID LNAME FNAME
---------- -------------------- --------------------
14 kong unkown
15 kongkong unkown
55 kong3 unknow
SQL> select * from test3
2 union
3 select * from test3;
ID LNAME FNAME
---------- -------------------- --------------------
14 kong unkown
15 kongkong unkown
55 kong3 unknow
SQL> select * from test3
2 union all
3 select * from test3;
ID LNAME FNAME
---------- -------------------- --------------------
14 kong unkown
15 kongkong unkown
55 kong3 unknow
14 kong unkown
15 kongkong unkown
55 kong3 unknow
已选择6行。
2,交集INTERSECT;
SQL> select id,lname from test3 where id>14;
ID LNAME
---------- --------------------
15 kongkong
55 kong3
SQL> select id,lname from test3 where lname like '%3%';
ID LNAME
---------- --------------------
55 kong3
SQL> select id,lname from test3 where id>14
2 intersect
3 select id,lname from test3 where lname like '%3%';
ID LNAME
---------- --------------------
55 kong3
3,差集:MINUS;
SQL> run
1 select id,lname from test3 where id>14
2 minus
3* select id,lname from test3 where lname like '%3%'
ID LNAME
---------- --------------------
15 kongkong
阅读(3134) | 评论(1) | 转发(0) |