易截截图软件、单文件、免安装、纯绿色、仅160KB

ORACLE WITH AS 用法

记得以前在论坛里看到inthirties用到过WITH AS这个字眼,当时没特别在意。今天在一个帖子里又看到有人用这个,所以就去网上搜了搜相关内容,自己小试了一把,写下来,方便以后忘了的话学习。
===================================================================================
先举个例子吧:
有两张表,分别为A、B,求得一个字段的值先在表A中寻找,如果A表中存在数据,则输出A表的值;如果A表中不存在,则在B表中寻找,若B表中有相应记录,则输出B表的值;如果B表中也不存在,则输出"no records”字符串。
 with
sql1 as (select to_char(a) s_name from test_tempa),
sql2 as (select to_char(b) s_name from test_tempb where not exists (select s_name from sql1 where rownum=1))
select * from sql1
union all
select * from sql2
union all
select 'no records' from dual
where not exists (select s_name from sql1 where rownum=1)
and not exists (select s_name from sql2 where rownum=1);
再举个简单的例子
with a as (select * from test)
select * from a;
其实就是把一大堆重复用到的SQL语句放在with as 里面,取一个别名,后面的查询就可以用它
这样对于大批量的SQL语句起到一个优化的作用,而且清楚明了
下面是搜索到的英文文档资料
About Oracle WITH clause
Starting in Oracle9i release 2 we see an incorporation of the SQL-99 “WITH clause”, a tool for materializing subqueries to save Oracle from having to re-compute them multiple times.
The SQL “WITH clause” is very similar to the use of Global temporary tables (GTT), a technique that is often used to improve query speed for complex subqueries. Here are some important notes about the Oracle “WITH clause”:
   • The SQL “WITH clause” only works on Oracle 9i release 2 and beyond.
   • Formally, the “WITH clause” is called subquery factoring
   • The SQL “WITH clause” is used when a subquery is executed multiple times
   • Also useful for recursive queries (SQL-99, but not Oracle SQL)
To keep it simple, the fo


相关文档:

[转载]Oracle存储过程学习

存储过程创建语法:
create or replace procedure 存储过程名(param1 in type,param2 out type) 
as
变量1 类型(值范围);
变量2 类型(值范围);
Begin
    Select count(*) into 变量1 from 表A where列名=param1;
    If (判断条件) then
    &n ......

oracle数据导入导出


单表数据迁移:支持clob,blob
      exp estarcom/estarcom@ORACLE  tables=AA direct=y file=C:/AAA1.dmp
   imp estarcom/estarcom@ORACLE  tables=AA  file=C:/AAA1.dmp fromuser=estarcom touser=estarcom
全库数据迁移
exp userid=zhongxin/zhongxin@ORACLE own ......

Oracle JDBC 自带连接池

 http://www.diybl.com/course/3_program/java/javajs/2008429/111906.html
如果要使用池的话,就必须使用OracleConnectionCacheImpl,共有三种池的策略:
DYNAMIC_SCHEME(是动态增加.用完如果超过上限则关掉)
The cache will create connections above the specified maximum limit
when necessary   but ......

oracle 回退段 ORA

回滚段用于对数据库修改时, 保存原有的数据, 以便稍后可以通过使用ROLLBACK来恢复到修改前的数据; 另外, 回滚段可以为数据库中的所有进程提供读一致性. 因此, 回滚段设置的合理与否, 直接影响到数据库的性能.
回滚段的维护及查询
(1) 创建回滚段
__CREATE ROLLBACK SEGMENT RB01
__TABLESPACE RBS1
__STORAGE (
____I ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号