数据库原理

2021/6/14 19:24:17

本文主要是介绍数据库原理,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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 ‘\’        这样紧跟在\后面的字符_不再具有通配符的含义,转义为普通的_



这篇关于数据库原理的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程