About me:Oracle ACE pro,optimistic,passionate and harmonious.
Focus on ORACLE,MySQL and other database programming,peformance tuning,db design, j2ee,Linux/AIX,Architecture tech,etc
DINGJUN123>drop table c;
表已删除。
DINGJUN123>create table a as
2 select level id,'x'||level name
3 from dual connect by level<5
4 union all
5 select level,'y'||level
6 from dual connect by level<5;
表已创建。
DINGJUN123>create table b as
2 select level id,'x'||level name
3 from dual connect by level<3;
表已创建。
DINGJUN123>create table c as
2 select level id,'y'||level name
3 from dual connect by level<3;
表已创建。
DINGJUN123>select * from a;
ID NAME
---------- --------------------
1 x1
2 x2
3 x3
4 x4
1 y1
2 y2
3 y3
4 y4
已选择8行。
DINGJUN123>select * from b;
ID NAME
---------- --------------------
1 x1
2 x2
已选择2行。
DINGJUN123>select * from c;
ID NAME
---------- --------------------
1 y1
2 y2
已选择2行。
DINGJUN123>set null null
------------------------------test1: outer-join use old syntax--------------------------
DINGJUN123>select *
2 from a,b
3 where a.id = b.id(+) and a.name like 'x%';
ID NAME ID NAME
---------- -------------------- ---------- --------------------
1 x1 1 x1
2 x2 2 x2
3 x3 null null
4 x4 null null
已选择4行。
-------------------------------test2: outer-join use new syntax-------------------------- --NO.1: only use 'on' clause,not 'where' clause
DINGJUN123>select *
2 from a left join b
3 on a.id =b.id and a.name like 'x%';
ID NAME ID NAME
---------- -------------------- ---------- --------------------
1 x1 1 x1
2 x2 2 x2
3 x3 null null
4 x4 null null
1 y1 null null
2 y2 null null
3 y3 null null
4 y4 null null
已选择8行。
--NO.2:use 'on' and 'where' clause
DINGJUN123>select *
2 from a left join b
3 on a.id =b.id
4 where a.name like 'x%';
ID NAME ID NAME
---------- -------------------- ---------- --------------------
1 x1 1 x1
2 x2 2 x2
4 x4 null null
3 x3 null null
已选择4行。
DINGJUN123>select *
2 from a left join b
3 on a.name like 'x%'
4 where a.id=b.id; ID NAME ID NAME
---------- -------------------- ---------- --------------------
1 x1 1 x1
2 x2 2 x2 已选择2行。 --Questions: what can you conclude from these analytics?
--something else? please wait.......