在oracle中关于树的sql
表task,字段id_,name_
id_的数据如下形式:
1
1.1
1.1.1
1.1.1.2
1.2
1.2.1
...
10
10.1
10.1.1
10.2.1
10.2.1.1
10.2.1.1.1
10.2.1.1.2
.......
注:“.”标识父子的关系。
现在通过id_查询树结构的效果,并且知道此节点是否为叶子节点leaf。。?
语句如下:
select
id_ ,
name_ ,
(select count(id_) from task where t.id_= substr(id_,0,INSTR((id_),'.',-1)-1) ) as leaf,connect_by_isleaf from task t
start with t.id_ ='5' connect by prior
t.id_= substr(t.id_,0,INSTR((t.id_),'.',-1)-1) order by t.id_
相关文档:
方法一:
1) 查看服务器端字符集: &nbs ......
在Oracle8i或以上版本中,可以创建以下两种临时表:
1。会话特有的临时表
CREATE GLOBAL TEMPORARY ()
ON COMMIT PRESERVE ROWS;
2。事务特有的临时表
CREATE GLOBAL TEMPORARY