oracle 层次化查询
层次化查询:
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)
相关文档:
练习了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; ......
对于 Oracle 的 rownum 问题,很多资料都说不支持>,>=,=,between...and,只能用以上符号(<、<=、!=),并非说用>,>=,=,between..and 时会提示SQL语法错误,而是经常是查不出一条记录来,还会出现似乎是莫名其妙的结果来,其实您只要理解好了这个 rownum 伪列的意义就不应该感到惊奇,同样是伪列,rownum ......
软件下载
到http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html下载如下三个包:
instantclient-basic-win32-11.1.0.7.0.zip
instantclient-jdbc-win32-11.1.0.7.0.zip
instantclient-sqlplus-win32-11.1.0.7.0.zip
将这三个包分别解压,然后内容放到D:\instantclient_11_1下
......
以下是Oracle JDBC官方文档的说法:
也就是随便翻译一下就理解了。
JDBC Thin for All Platforms
classes12.jar (1,600,090 bytes) - for use with JDK 1.2 and JDK 1.3
在低级JDK版本1.2与1.3中使用的驱动,虽然实际上在1.4,1.5中使用大部分情况也是OK的
classes12_g.jar (2,044,594 bytes) - same as classes12.j ......
不可以用保留字做为表名,字段名的。
如果用单个英语单词或词组来表示表名或字段名。这比较容易和保留字冲突。如何知道Oracle用了哪些保留字呢?
系统表v$reserved_words中存放了所有的保留字。
select * from v$reserved_words;
Oracle有500个保留字,记住所有的保留字有点困难,每次都查找会影响到开发速度,如 ......