Usage of select... connect by prior... start with and (+) in oracle

Source: Internet
Author: User

Select... in oracle... connect by prior... start with and (+) usage 1. select... connect by prior... usage of start with: select... from <tablename> where <conditional-1> -- filter condition, used to filter all returned records start with <conditional-2> -- query results from the start of the root node with the conditions connect by prior <conditional-3> -- the connection condition database table structure is as follows: create table tablename (id number, root_id number, name varchar2 (50), desc varchar2 (250) insert into tablename (id, root_id, name, desc) values (, 'Root', 'root node'); insert into tablename (id, root_id, name, desc) values (, 'childnode1', 'subnode 1 '); insert into tablename (id, root_id, name, desc) values (3,1, 'childnode2', 'subnode 2'); insert into tablename (id, root_id, name, desc) values (, 'root2', 'root node 2'); insert into tablename (id, root_id, name, desc) values (, 'childnodea ', 'subnode 1'); insert into tablename (id, root_id, name, desc) values (6, 4, 'childnodeb', 'subnode 2'); get the complete tree: Select * from tablename connect by prior id = root_id start with root_id = 0 if the prior in connect by prior is omitted, the query will not undergo deep recursion. For example, select * from tablename connect by id = root_id start with root_id = 0 2. usage of (+) (outer join) in oracle select. id, B. idd from a, B WHERE. id (+) = B. IDD is equivalent to select. id, B. idd from a right outer join B ON (. id = B. the data in table B is retrieved when two tables are associated. The data in table A is retrieved only when table B has the corresponding data.

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.