Oracle recursive operations (Tree operations) start with org_id = '1' connect by prior parent_id = son_id 1. preface oracle recursive operations are often used in the directory structure on our web pages. It is said that they are frequently asked questions during interviews, and some online things are not very clear, so I sorted it out myself. The following mainly uses an example to illustrate how to directly copy the code and run it. Www.2cto.com 2. start with org_id = 'condition 1' prior parent_id = son_id; this is used to retrieve all the tree structures and store the tree directories in the same table, such as 1 | -- 2 | -- 3 | -- 4 | -- 5 | -- 6 | -- 7 | -- 8 | -- 9 | -- 10 www.2cto.com, connect by perior is useful for this special query. 3. code Java code create table TESTTEMP (parent_ID VARCHAR2 (30), son_ID VARCHAR2 (30); insert into TESTTEMP values ('1', '0 '); insert into TESTTEMP values ('1', '2'); insert into TESTTEMP values ('1', '3'); insert into TESTTEMP values ('1 ', '4'); insert into TESTTEMP values ('1', '7'); insert into TESTTEMP values ('4', '5 '); insert into TESTTEMP values ('5', '6'); insert into TESTTEMP values ('7', '8'); insert into T ESTTEMP values ('8', '9'); insert into TESTTEMP values ('9', '10'); commit; select * from TESTTEMP start with parent_ID = '1' connect by parent_ID = prior son_ID www.2cto.com result: 1 0 1 2 1 3 4 4 5 5 6 1 7 7 8 8 9 9 10 4. To sum up the above example, the function is to traverse all nodes. If prior is placed after connect by, it is searched from the top.