1、 关系R和S交操作对应的SQL语句:
Select * from R INTERSECT Select * from S
或 Select * from R where sname in(select sname from S)
2、 差操作对应的SQL语句:
Select * from R EXCEPT select * from S
或 Select * from R where sname not in(select sname from S)
3、 并操作对应的SQL语句:
Select * from R Union Select * from S
注意:UNION ALL 保留重复元组
4、 笛卡尔积:
Select * from R, S
或 Select * from R CROSS JOIN S
5、 投影运算:
Select SingerID, Name from Singer
6、 选择运算:
Select * from Singer where Gender = ‘男’
7、 自然连接:
Select A, R.B, C, E from R join S on R.B = S.B
外连接:
Select A, R.B, C, E from R outer join S on R.B = S.B
左外连接:
Select A, R.B, C, E from R left outer join S on R.B = S.B
右外连接:
Select A, R.B, C, E from R right outer join S on R.B = S.B
8、 连接(join)
Select R.*, S.* from R, S where C < E
等值连接
Select R.*, S.* from R, S where R.B = S.B
9、 除法
Select distinct Sname from R as X where not exists(select * from S where not exists(select * from R as Y where Y.Cname = S.Cname and Y.Sname = X.Sname))
10、 通配符%代表任意长度(包括长度为0)的字符串,_则代表任意单个字符。
11、select * from Singers where Name like ‘Joht\_%’ escape ‘\’ 这样紧跟在\后面的字符_不再具有通配符的含义,转义为普通的_