오라클 limit

출처 :

http://comeng.andong.ac.kr/%7Echi23/bbs/view.php?id=downdoli_db&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=hit&desc=desc&no=2

 

보통 my-sql에서는 PK로 잡고 auto-increment를 많이 사용하는데
이를 오라클 DB로 마이그레이션 하면서 다음과 같이 한다.....

원본 my-sql 쿼리:
select no, gno, ono, nested, id, name, title, registerDate, readno ]
from tableName
order by gno desc, ono asc limit 0, 15

오라클로 변환된 쿼리
select *
from (select a.*,rownum rnum from
(select * from table_notice order by gno desc, ono asc) a)
where rnum >  페이지당 리스트 수* ( 원하는페이지 번호 - 1) and rownum <= 페이지당 리스트 수

rownum으로 번호를 매기는 것이 order by보다 우선 순위가 높단다.
그리고 위의 방식 말고도 인덱스를 이용한 방법도 있는데..

뭐 이것도 쓸만하지만 더 쓸만한건 ;;;; 내가 품고 이찌롱 ^_^

Posted by 웅쓰

2007/09/27 17:41 2007/09/27 17:41
Response
No Trackback , 10 Comments
RSS :
http://comefeel.com/tt/comefeel/rss/response/340

Trackback URL : http://comefeel.com/tt/comefeel/trackback/340

« Previous : 1 : ... 88 : 89 : 90 : 91 : 92 : 93 : 94 : 95 : 96 : ... 357 : Next »

블로그 이미지

웅자의 상상플러스

- 웅쓰

Archives

Authors

  1. 웅쓰

Recent Trackbacks

Calendar

«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Site Stats

Total hits:
289618
Today:
19
Yesterday:
329