ORACLE 8i, 9i table connection method. Normal equal connections:
Select * from a, B where a. id = B. id;
This is an internal connection.
For external connections:
"(+)" Can be used in Oracle, and 9i can use LEFT/RIGHT/full outer join.
Left outer join: LEFT OUTER JOIN
SELECT e. last_name, e. department_id, d. department_name
FROM employees e
Left outer join orders ments d
ON (e. department_id = d. department_id );
Equivalent
SELECT e. last_name, e. department_id, d. department_name
FROM employees e, departments d
WHERE e. department_id = d. department_id (+)
Result: Records of all employees and their respective departments, including records of employees who do not have the corresponding department number department_id.
Right outer join: RIGHT OUTER JOIN
SELECT e. last_name, e. department_id, d. department_name
FROM employees e
Right outer join orders ments d
ON (e. department_id = d. department_id );
Equivalent
SELECT e. last_name, e. department_id, d. department_name
FROM employees e, departments d
WHERE e. department_id (+) = d. department_id
Result: Records of all employees and their respective departments, including records of departments without any employees.
Full outer join: FULL OUTER JOIN
SELECT e. last_name, e. department_id, d. department_name
FROM employees e
Full outer join orders ments d
ON (e. department_id = d. department_id );
Result: Records of all employees and their respective departments, including employee records without the corresponding department number department_id and department records without any employees.
ORACLE8i is a syntax that does not directly support full outer join. That is to say, you cannot add (+) to both the left and right tables. The following is the complete Outer Join syntax that can be referenced in ORACLE8i.
Select t1.id, t2.id from table1 t1, table t2 where t1.id = t2.id (+)
Union
Select t1.id, t2.id from table1 t1, table t2 where t1.id (+) = t2.id
Connection Type |
Definition |
Illustration |
Example |
Internal Connection |
Connect only matched rows |
|
Select A. c1, B. c2 from A join B on A. c3 = B. c3; |
Left Outer Join |
Contains all rows in the left table (no matter whether the table on the right has rows that match them) and all matched rows in the right table |
|
Select A. c1, B. c2 from A left join B on A. c3 = B. c3; |
Outer right connection |
Contains all rows in the right table (no matter whether the table on the left has rows that match them) and all matched rows in the left table |
|
Select A. c1, B. c2 from A right join B on A. c3 = B. c3; |
All external connections |
Contains all rows in the left and right tables, regardless of whether the tables on the other side have rows matching them. |
|
Select A. c1, B. c2 from A full join B on A. c3 = B. c3; |
(Theta) Connection |
Use conditions other than equivalence to match rows in the left and right tables |
|
Select A. c1, B. c2 from A join B on A. c3! = B. c3; |
Cross join |
Generate Cartesian Product -- it does not use any matching or selection conditions, but directly matches each row in a data source with each row in another data source. |
|
Select A. c1, B. c2 from A, B; |