WITH查询


WITH查询

为什么要用WITH?

1. 如果需要在一段复杂查询里多次应用同一个查询,用WITH可实现代码重用;

2. WITH查询类似将查询结果保留到用户临时表里,在大的复杂查询中可以减少IO,有一定的性能优化作用。

WITH查询有何限制与特性?

1. 如果当前schema下有与WITH查询别名相同的表,查询中WITH查询别名优先;

2. 只能用于select 语句;

3. WITH可包含一个或多个查询;

4. WITH查询可被其它查询或WITH查询引用。

转自:http://www.cnblogs.com/xublogs/archive/2011/08/29/2292173.html


下为OCP试题


Which statements are true regarding the usage of the WITH clause in complex correlated subqueries?
(Choose all that apply.)
A. It can be used only with the SELECT clause.
B. The WITH clause can hold more than one query.
C. If the query block name and the table name were the same, then the table name would take
precedence.
D. The query name in the WITH clause is visible to other query blocks in the WITH clause as well as to
the main query block.
Answer: ABD
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值