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)