层次化查询:
select [level],colomn,...from table
[where where_clause]
[ [start with start_condition] [connect by prior prior_condition] ];
,使用count(distinct level) 可以获取层次数
从下向上遍历,交换connect by prior 父节点和子结点的顺序即可
要去掉某个节点及其自己点在查询结果中,可以在connect by prior 子句中使用and condition 即可。
只去掉某节点,而保留子结点,只需在where 中添加条件即可
层次化查询中也可以使用子查询
利用查询修改,语句
update table T set sid = (select pid from T2 where T.sno = T2.sno)
where exists (select 1 from T2 where T.sno = T2.sno)