oracle查询时几种连接方式
2014-11-10 14:14
295 查看
oracle查询时几种连接方式
1、内连接
只显示出两张表都匹配的结果select * from student ,score where student.id=score.stuid//隐式内连接
select * from student inner join score where student.id=score.stuid//显式内连接
2、外连接
有条件的显示出表的内容1)左外连接
显示出左边表的全部字段和右边表中与左边匹配的字段,空的用null补齐
select * from student left join score on student.id=score.stuid
2)右外连接
显示出右边表的全部字段和左边表中与右边匹配的字段,空的用null补齐
select * from student right join score on student.id=score.stuid
3)全连接
显示两张表的全部字段
select * from student full join score on student.id=score.stuid
3、(+)操作符
1)这是oracle9i以前的操作符,相当于外连接2)左外连接
select * from student, score where onstudent.id=score.stuid(+)
3)右外连接
select * from student, score where onstudent.id(+)=score.stuid
4)注意:
当使用(+)操作符执行外连接时,应当将该操作符放在显示较少行(完全满足连接条件行)一端。
(+)操作符只能出现在where子句中,并且不能与outer join语法同时使用。
当使用(+)操作符执行外连接时,如果在where语句中包含多个条件,则必须在所有的条件中都包含(+)操作符。
(+)操作符只能适用于列,而不能适用于表达式。
(+)操作符不能与or和in操作符一起使用。
(+)操作符只能用于左外连接和右外连接,不能用于实现完全连接。
4、筛选条件关键词及效率
1)on 一般做外连接时和join配合使用2)where一般做隐式内连接使用
3)having一般存在聚合函数时必须使用
效率: on>where>having
相关文章推荐
- oracle连接数据库,你有几种方式?
- ORACLE之 几种常用的表连接方式
- C# 连接 Oracle 的几种方式
- 连接Oracle的几种方式
- net 连接oracle的几种方式
- .net 连接oracle的几种方式 .
- .net 连接oracle的几种方式
- C# 连接 Oracle 的几种方式
- 【Oracle】表的几种连接方式
- C# 连接 Oracle 的几种方式
- net 连接oracle的几种方式
- Oracle中表的连接方式查询讲解
- .net 连接oracle的几种方式
- ORACLE 数据去重查询的几种常见方式
- .net 连接oracle的几种方式
- C# 连接 Oracle 的几种方式
- .net 连接oracle的几种方式
- oracle 数据库中几种连接方式执行过程(nested loop、hash join、sort order join)
- net 连接oracle的几种方式 .
- C# 连接 Oracle 的几种方式[转]