What happened during oracle connection

Source: Internet
Author: User
Tags dname

In oracle connection, in addition to returning rows that meet the connection conditions, the two [SQL] tables return rows that do not meet the conditions in the left (or right) table, this connection is called a left (right) Outer Join. In addition to returning rows that meet the connection conditions, the two tables return rows that do not meet the conditions during the connection process. This connection is called a full outer join. Select empno, ename, sal, dname, loc from emp, dept where emp. deptno = dept. deptno; SELECT emp. column, dept. column -- right Outer Join FROM emp, dept WHERE emp. column (+) = dept. column; SELECT emp. column, dept. column -- left Outer Join FROM emp, dept WHERE emp. column = dept. column (+); the outer join symbol is (+), and (+) should be placed behind the field name. The table opposite to (+) is displayed in all. When the left outer join, the plus sign is on the right of the equal sign select d. dname, e. ename, e. deptno from dept d, emp e where d. deptno = e. deptno (+) order by d. deptno; select empno, ename, job, sal, dept. deptno, dname, loc 2 from emp, dept 3 where emp. deptno (+) = dept. deptno; 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); self-join: the image of the table itself is treated as another table SELEC T worker. last_name | 'Works for '| manager. last_name FROM employees worker, employees manager WHERE worker. manager_id = manager. employee_id; Cartesian sets are generated under the following conditions: the omitted join conditions are invalid. All rows in all tables are connected to each other. To avoid Cartesian sets, a valid join condition can be added to the WHERE clause. In the actual operating environment, avoid using the cross join clause to generate a CROSS set for the joined table. The cross set and Cartesian set are the same. SELECT last_name, department_name FROM employees cross join orders; naturally connected to the natural join clause, the equivalent JOIN is created based on the columns with the same name in two tables. Query the data that meets the equivalence conditions in the table. If the column names are the same and the data types are different, an error is returned. SELECT department_id, department_name, location_id, city FROM orders natural join locations; Use the USING clause to create a connection when the natural join clause creates an equijoin, you can use the USING clause to specify the columns to be used in the equijoin. You can use USING to select when multiple columns meet the conditions. Do not add the prefix or alias of the table name to the selected column. Natural join and USING clauses are often used at the same time. SELECT e. employee_id, e. last_name, d. location_id FROM employees e JOIN orders ments d USING (department_id); USING the ON clause to create a connection to a natural connection is a JOIN condition in a column with the same name. You can use the ON clause to specify additional connection conditions. This connection condition is separate from other conditions. The ON clause makes the statement more readable. SELECT e. employee_id, e. last_name, e. department_id, d. department_id, d. location_id FROM employees e JOIN orders ments d ON (e. department_id = d. department_id); Use the ON clause to create multi-table join select employee_id, city, department_name FROM employees e JOIN orders d ON d. department_id = e. department_id JOIN locations l ON d. location_id = l. location_id;

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.