Using the Connect by PRIOR START with statement in Oracle

Source: Internet
Author: User

Syntax: Connect by is used in structured queries with the following basic syntax:

Start With,connect by main purpose: Remove the tree data from the table. Each piece of data that can be assumed to be stored in a table is a node in the tree, respectively.

Select ... from tablename start with condition 1connect by prior condition 2where condition 3; wherein: Condition 1 is the root node limit statement, of course, can also relax the limited conditions to take multiple nodes, forming multiple trees. Condition 2 is the join condition. Condition 3 is the filter condition that is used to filter all records returned. For example SELECT * from Tablestart with id = ' G113 ' connect by Prior id = pidwhere Fflag = ' Y '; There are two fields, IDs and PID in a tree-like storage table. Where PID is the ID of the ID ancestor record. All records of this tree can be obtained by querying the above syntax. Scan Order: 1, starting from the root node, 2, accessing the node, 3, judging the node has no access to the sub-node, if any, then to its leftmost non-visited sub-node, and perform the second step, otherwise perform the fourth step; 4, if the node is the root, then access is complete, otherwise fifth step; 5, Returns the parent node of the node and executes the third step; Select ... connect by {Prior column name 1 = column name 2| column name 1=prior column name 2}[start with];

Using the Connect by PRIOR START with statement in Oracle

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.