ORACLE连接类型 各种连接查询PL/SQL测试
2008-09-29 12:24
357 查看
---测试ORACLE 所有连接类型 PL/SQL 中执行的
--本人初学,可能有理解不到位的地方,请指正,谢谢!
--建表
create table xxaa (id number(10),name varchar2(20));
create table xxbb (idd number(10),namee varchar2(20));
--INSERT 数据,或者 FOR UPDATE 也可以
select * from xxaa for update;
select * from xxbb for update;
/* 表A 数据
1 1 a
2 2 b
3 3 c
4 4 d
5 e
6 f
*/
/* 表B数据
1 1 e
2 2 f
3 3 g
4 4 h
5 5 i
6 6 j
7 7 k
8 8 l
9 9
*/
---测试ORACLE 所有连接类型 PL/SQL 中执行的
--本人初学,可能有理解不到位的地方,请指正,谢谢!
--建表
create table xxaa (id number(10),name varchar2(20));
create table xxbb (idd number(10),namee varchar2(20));
--INSERT 数据,或者 FOR UPDATE 也可以
select * from xxaa for update;
select * from xxbb for update;
/* 表A 数据
1 1 a
2 2 b
3 3 c
4 4 d
5 e
6 f
*/
/* 表B数据
1 1 e
2 2 f
3 3 g
4 4 h
5 5 i
6 6 j
7 7 k
8 8 l
9 9
*/
select * from xxaa a,xxbb b where a.id(+)=b.idd;--右连接,以B表为基表,匹配B表中的都输出
select * from xxaa a,xxbb b where a.id=b.idd(+); --左连接,以A表为基表,匹配A表的都输出 相当于left join 和left outer Join
select * from xxaa a,xxbb b where a.id=b.idd; -- =连接 A,B表都匹配才输出
select * from xxaa a left join xxbb b on (a.id=b.idd); --左内连
select * from xxaa a right join xxbb b on (a.id=b.idd); --右内连
select * from xxaa a full join xxbb b on (a.id=b.idd); --完全连接 --A表和B表的 并集
select * from xxaa a inner join xxbb b on (a.id=b.idd); --内连接 --A表和B表的 交集
select * from xxaa a left outer join xxbb b on (a.id=b.idd);--左外连
select * from xxaa a right outer join xxbb b on (a.id=b.idd); --右外连
select * from xxaa a full outer join xxbb b on (a.id=b.idd); --完全外联
select * from xxaa a join xxbb b on (a.id=b.idd); --相当于= 连接
select * from xxaa a,xxbb b where a.id(+)=b.idd;--右连接,以B表为基表,匹配B表中的都输出
select * from xxaa a,xxbb b where a.id=b.idd(+); --左连接,以A表为基表,匹配A表的都输出 相当于left join 和left outer Join
select * from xxaa a,xxbb b where a.id=b.idd; -- =连接 A,B表都匹配才输出
select * from xxaa a left join xxbb b on (a.id=b.idd); --左内连
select * from xxaa a right join xxbb b on (a.id=b.idd); --右内连
select * from xxaa a full join xxbb b on (a.id=b.idd); --完全连接 --A表和B表的 并集
select * from xxaa a inner join xxbb b on (a.id=b.idd); --内连接 --A表和B表的 交集
select * from xxaa a left outer join xxbb b on (a.id=b.idd);--左外连
select * from xxaa a right outer join xxbb b on (a.id=b.idd); --右外连
select * from xxaa a full outer join xxbb b on (a.id=b.idd); --完全外联
select * from xxaa a join xxbb b on (a.id=b.idd); --相当于= 连接
--本人初学,可能有理解不到位的地方,请指正,谢谢!
--建表
create table xxaa (id number(10),name varchar2(20));
create table xxbb (idd number(10),namee varchar2(20));
--INSERT 数据,或者 FOR UPDATE 也可以
select * from xxaa for update;
select * from xxbb for update;
/* 表A 数据
1 1 a
2 2 b
3 3 c
4 4 d
5 e
6 f
*/
/* 表B数据
1 1 e
2 2 f
3 3 g
4 4 h
5 5 i
6 6 j
7 7 k
8 8 l
9 9
*/
---测试ORACLE 所有连接类型 PL/SQL 中执行的
--本人初学,可能有理解不到位的地方,请指正,谢谢!
--建表
create table xxaa (id number(10),name varchar2(20));
create table xxbb (idd number(10),namee varchar2(20));
--INSERT 数据,或者 FOR UPDATE 也可以
select * from xxaa for update;
select * from xxbb for update;
/* 表A 数据
1 1 a
2 2 b
3 3 c
4 4 d
5 e
6 f
*/
/* 表B数据
1 1 e
2 2 f
3 3 g
4 4 h
5 5 i
6 6 j
7 7 k
8 8 l
9 9
*/
select * from xxaa a,xxbb b where a.id(+)=b.idd;--右连接,以B表为基表,匹配B表中的都输出
select * from xxaa a,xxbb b where a.id=b.idd(+); --左连接,以A表为基表,匹配A表的都输出 相当于left join 和left outer Join
select * from xxaa a,xxbb b where a.id=b.idd; -- =连接 A,B表都匹配才输出
select * from xxaa a left join xxbb b on (a.id=b.idd); --左内连
select * from xxaa a right join xxbb b on (a.id=b.idd); --右内连
select * from xxaa a full join xxbb b on (a.id=b.idd); --完全连接 --A表和B表的 并集
select * from xxaa a inner join xxbb b on (a.id=b.idd); --内连接 --A表和B表的 交集
select * from xxaa a left outer join xxbb b on (a.id=b.idd);--左外连
select * from xxaa a right outer join xxbb b on (a.id=b.idd); --右外连
select * from xxaa a full outer join xxbb b on (a.id=b.idd); --完全外联
select * from xxaa a join xxbb b on (a.id=b.idd); --相当于= 连接
select * from xxaa a,xxbb b where a.id(+)=b.idd;--右连接,以B表为基表,匹配B表中的都输出
select * from xxaa a,xxbb b where a.id=b.idd(+); --左连接,以A表为基表,匹配A表的都输出 相当于left join 和left outer Join
select * from xxaa a,xxbb b where a.id=b.idd; -- =连接 A,B表都匹配才输出
select * from xxaa a left join xxbb b on (a.id=b.idd); --左内连
select * from xxaa a right join xxbb b on (a.id=b.idd); --右内连
select * from xxaa a full join xxbb b on (a.id=b.idd); --完全连接 --A表和B表的 并集
select * from xxaa a inner join xxbb b on (a.id=b.idd); --内连接 --A表和B表的 交集
select * from xxaa a left outer join xxbb b on (a.id=b.idd);--左外连
select * from xxaa a right outer join xxbb b on (a.id=b.idd); --右外连
select * from xxaa a full outer join xxbb b on (a.id=b.idd); --完全外联
select * from xxaa a join xxbb b on (a.id=b.idd); --相当于= 连接
相关文章推荐
- Oracle 多表查询连接的三种类型
- 两张图解读Oracle 数据库的 union all、union、intersect、minus以及各种连接查询。
- 数据库查询中的各种连接类型
- 【读书笔记】【收获,不止Oracle】不同连接类型表下,驱动顺序对查询性能的影响
- 文章推荐:Oracle各种连接查询
- 数据库查询中的各种连接类型
- SQL各种连接查询详解(左连接、右连接..)
- Oracle学习笔记 -- day05 多表查询、连接查询、子查询、分页、行转列、集合运算
- 解决在mybatis中使用CTE进行oracle查询数据类型为long的字段出现流关闭问题
- Oracle中的连接查询
- Oracle中表的连接方式查询讲解
- oracle复合类型---嵌套表模糊查询
- oracle 定长字段查询问题 ,ibatis 与pl/sql查询的char类型字段查询不同
- mybatis 使用oracle char类型查询不到结果
- sql的各种连接查询
- oracle之连接查询及子查询举例
- linux shell脚本连接oracle查询数据插入文件和日志文件中
- ORACLE复杂查询之连接查询
- Oracle 连接查询的理解
- Oracle查询隐式类型转换不走索引