1. 命令
- 集合并:union
- 集合交:intersect
- 集合差:except(minus)
注意:集合操作自动去掉重复元组,如果要保留重复元组的话,必须用all关键字指明。
2. 例子
- 例1
求选修了001或(且)002号课程的学生号。
(select SNO from SC where CNO = 001)
union(intersect)
(select SNO from SC where CNO = 002)
- 例2
求选修了001或002号而没有选003课程的学生号。
(selec SNO from SC where CNO = 001 or CNO = 002)
except
(selec SNO from SC where CNO = 003)