CONNECT BY 子句在层次查询中说明父与子行间的关系。该子句包含一个定义该SELECT 关系的条件。这些条件的有些部分必须使用PRIOR操作符来应用父行,包含PRIOR操作符的条件部分必须用如下格式之一:
    PRIOR expression comparison_operator expression
    expression comparison_operator PRIOR expressionTo find the children of a parent row, Oracle evaluates the PRIOR expression for the parent row and the other expression for each row in the table. Rows for which the
condition is true are the children of the parent. The CONNECT BY clause can
contain other conditions to further filter the rows selected by the query. The
CONNECT BY clause cannot contain a subquery.
If the CONNECT BY clause results in a loop in the hierarchy, Oracle returns an
error. A loop occurs if one row is both the parent (or grandparent or direct
ancestor) and a child (or a grandchild or a direct descendent) of another row.
Example I. The following CONNECT BY clause defines a hierarchical relationship
in which the EMPNO value of the parent row is equal to the MGR value of the
child row:
CONNECT BY PRIOR empno = mgr;
Example II. In the following CONNECT BY clause, the PRIOR operator applies
only to the EMPNO value. To evaluate this condition, Oracle evaluates EMPNO
values for the parent row and MGR, SAL, and COMM values for the child row:
CONNECT BY PRIOR empno = mgr AND sal > comm;
To qualify as a child row, a row must have a MGR value equal to the EMPNO value
of the parent row and it must have a SAL value greater than its COMM value.