Oracle SQL internal connection left Outer connection right outer connection full outer connection

Source: Internet
Author: User

1. Create a test table and prepare the test data
[Email protected]> CREATE Table A (a number (1), b number (1), c number (1));
[Email protected]> CREATE TABLE B (a number (1), D number (1), E number (1));
[Email protected]> INSERT into a values (1,1,1);
[Email protected]> INSERT into a values (2,2,2);
[Email protected]> INSERT into a values (3,3,3);
[Email protected]> insert INTO B values (1,4,4);
[Email protected]> insert INTO B values (2,5,5);
[Email protected]> insert INTO B values (4,6,6);
[Email protected]> commit;

[Email protected]> select * from A;

A B C
---------- ---------- ----------

1 1 1

2 2 2

3 3 3


[Email protected]> select * from B;


A D E
---------- ---------- ----------

1 4 4

2 5 5

4 6 6

2. Internal connection
[Email protected]> Select * from a, b where a.a=b.a;
Another way to do this is
[Email protected]> SELECT * from a INNER join B on A.A=B.A;


A B C a D E

-------- ---------- ---------- ---------- ---------- ----------

1 1 1 1 4 4

2 2 2 2 5 5

3. Left Outer connection
[Email protected]> select * from a b where A.A=B.A (+);
Another way to do this is
[Email protected]> select * from a LEFT outer join B on A.A=B.A;


A B C a D E
---------- ---------- ---------- ---------- ---------- ----------

1 1 1 1 4 4

2 2 2 2 5 5

3 3 3

4. Right outer connection
[Email protected]> select * from a b where A.A (+) =B.A;
Another way to do this is
[Email protected]> Select * from a right outer join B on A.A=B.A;


A B C a D E
---------- ---------- ---------- ---------- ---------- ----------

1 1 1 1 4 4

2 2 2 2 5 5

4 6 6
5. Full-Outer connection
[Email protected]> SELECT * from a full outer join B on A.A=B.A;


A B C a D E
---------- ---------- ---------- ---------- ---------- ----------

1 1 1 1 4 4

2 2 2 2 5 5

3 3 3

4 6 6

Oracle SQL internal connection left Outer connection right outer connection full outer connection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.