在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 ......
函数:
1.使用Create Function 语句创建
2.语
法:
Create or replace Function 函数名[参数列表]
Return 数据类型
IS|AS
局部变量
Be ......
日常开发活动中,有时候需要对oracle执行计划进行监控,以此来调优程序和数据库方面的性能。
常用方法有以下几种:
一、通过PL/SQL Dev工具
1、直接File->New->Explain Plan Window,在窗口中执行sql可以查看计划结果。其中,Cost表示cpu的消耗,单位为n%,Cardinality表示执行的行数,等价Row ......
TO_DATE格式(以时间:2007-11-02 13:45:25为例)
Year:
yy two digits 两位年 ......