在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_
相关文档:
练习了ORACLE类似的分页,目的:ORACLE的LIMIT使用
declare
type name_arrary_type is varray(20) of varchar2(10);
name_arrary name_arrary_type;
rowss int:=&输入页记录数;
dpno int:=&输入部门号;
v_count int:=0;
cursor emp_cursor(dpno int) is select ename from emp where deptno=dpno; ......
SQLPlus是oracle提供的一个命令行执行的工具
SQLPlus中用两种命令:
sqlplus:以命令行的方式进入数据库连接
sqlplusw:以窗口的形式启动命令行工具 注:主机字符串,输入数据库名称
&n ......
ASM:Automatic Storage Management, 是Oracle 主推的一种面向Oracle的存储解决方案, ASM 和 RDBMS 非常相似,ASM 也是由实例和文件组成, 也可以通过sqlplus 工具来维护。
1. ASM 实例由SGA 和后台进程组成。
1.1 SGA  ......
TO_DATE格式(以时间:2007-11-02 13:45:25为例)
Year:
yy two digits 两位年 ......