赞
踩
一.首先在本地数据库中执行如下sql操作
- create table test_table_user(id number primary key,name varchar(32));
- create table test_table_order(id number primary key,des varchar(32),user_id number,foreign key(user_id) references test_table_user(id));
- select *from test_table_user;
- select *from test_table_order;
- insert into test_table_user(id, name) values(1,'cuiyaonan20');
- insert into test_table_user(id, name) values(2,'cuiyaonan200');
- insert into test_table_user(id, name) values(3,'cuiyaonan2000');
- insert into test_table_user(id, name) values(4,'cuiyaonan2000@163.com');
-
- insert into test_table_order values(1,'cuiyaonan20 des',1);
- insert into test_table_order values(2,'cuiyaonan200 des',2);
- insert into test_table_order values(3,'cuiyaonan2000 des',3);
- insert into test_table_order(id,des) values(4,'cuiyaonan2000@163.com des');
plsql显示内容如下所示:
二. 左外连接
实现方式1(outer可以省略):
select * from test_table_user left outer join test_table_order on test_table_user.id = test_table_order.user_id;
显示数据为:
实现方式2:
select *from test_table_user ,test_table_order where test_table_user.id = test_table_order.user_id(+);
显示数据为
方式1与方式2完全一致, oracle 规范推荐用方式1
三. 右外连接
方式1(outer可以省略):
select *from test_table_user right outer join test_table_order on test_table_user.id = test_table_order.user_id;
显示数据为:
方式2:
select *from test_table_user ,test_table_order where test_table_user.id(+) = test_table_order.user_id;
显示数据位:
四.全连接
执行sql:
select * from test_table_user full join test_table_order on test_table_user.id = test_table_order.user_id;
显示结果:
五 where 后条件连接
执行sql:
select *from test_table_user ,test_table_order where test_table_user.id = test_table_order.user_id;
显示结果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。