Home > Database > Mysql Tutorial > 立此存照(1).oracle中的联接(join)问题

立此存照(1).oracle中的联接(join)问题

WBOY
Release: 2016-06-07 15:27:54
Original
1155 people have browsed it

1.oracle中联接(join)分为内联接(inner)和外联接(outer join),而外联接(outer join)又分为 左外联接(left outer join)和右外联接(right outer join)。 2. select * from TEST2; select * from TEST3; (1)笛卡尔乘积(Cartesian Product) select * from TEST2

1.oracle中联接(join)分为内联接(inner)和外联接(outer join),而外联接(outer join)又分为

左外联接(left outer join)和右外联接(right outer join)。

2.

select * from TEST2;
Copy after login

立此存照(1).oracle中的联接(join)问题

select * from TEST3;
Copy after login

立此存照(1).oracle中的联接(join)问题

(1)笛卡尔乘积(Cartesian Product)

  select * from TEST2, TEST3;
Copy after login

结果:

立此存照(1).oracle中的联接(join)问题

(2)内联接(inner join)

select * from 
TEST2 inner join TEST3 on test3.c2 = test2.c2;
Copy after login

结果:

立此存照(1).oracle中的联接(join)问题

(3)外联接(outer join)--作用:由于显示悬浮元祖

  2.1 右外联接(right outer join)

    select * from TEST2 right outer join TEST3 on TEST2.C2 = TEST3.C2;--usage 1
    select * from TEST2, TEST3 where TEST2.C2(+) = TEST3.C2;--usage 2
Copy after login

上述2条语句均表示右外联接

结果:

立此存照(1).oracle中的联接(join)问题

  2.2 左外联接(left right join)

    select * from TEST2 left outer join TEST3 on TEST2.C2 = TEST3.C2;--usage 1
    select * from TEST2, TEST3 where TEST2.C2 =TEST3.C2(+);--usage 2
Copy after login

    上述2条语句均表示左外联接

结果:

立此存照(1).oracle中的联接(join)问题

附录:数据库关于联接的概念

1.悬浮元素(dangling tuple):在一个联接中,若一个元组不能和另一个关系中的任何一个元组配对的话,该元组就成为悬浮元祖。

2.(1)笛卡尔乘积(2)积(3)交叉乘积 均表示同一个意思。

3.自然联接(natural join)

  3.1.先做条件联接

  3.2.对2个相同属性合并





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template