以前记在笔记上的一点东西,贴上来,省得以后丢了笔记,忘记了
Oracle 分页
select a.*, rownum r
from (select * from lg_order o order by o.order_id) a
where rownum <= 20
and rownum >= 10
select *
from (select a.*, rownum r
from (select * from lg_order o order by o.order_id) a
where rownum <= 20) b
where r >= 10
select *
from (select rid
from (select rownum rn, rid
from (select rowid rid from lg_order o order by o.order_id)
where rownum <= 20)
where rn >= 10) t1,
lg_order t2
where t2.rowid = t1.rid
第一句是错误的 由于rownum是一个总是从1开始的伪列,Oracle 认为这种条件不成立,查不到记录
执行顺序从内到外,从右到左
直接取物理地址最快
之前写错了,也没人指出,真是凄凉
posted on 2008-03-23 16:22
EvanLiu 阅读(10248)
评论(7) 编辑 收藏 所属分类:
Java基础 、
DB