Background Image

FORUM

2009.10.06 01:30

order siblings by 문의

조회 수 21109 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

맨 처음 실행하던 쿼리는 대충 아래와 같았습니다.


SELECT id, article_id, update_date, article_order, ROWNUM AS rnum, board_name, comm_name
FROM (
 SELECT id, article_id, update_date, article_order, ROWNUM AS rnum, board_name, comm_name
 FROM (
  SELECT t.id, t.article_id, t.update_date, t.article_order, board.name board_name, comm.name comm_name
  FROM tb_tree t, tb_tree board, tb_tree comm  WHERE t.board_id = board.id  AND t.comm_id = comm.id  AND t.comm_id = 174  AND board.status = 'Y'  ORDER BY article_order DESC) temp1 
 START WITH article_id = 0  CONNECT BY PRIOR id = article_id  ORDER SIBLINGS BY update_date DESC ) temp2 
where rnum BETWEEN 1 and 10


컬럼이나 where 절 등을 조금 생략하였기에 어색한 점이 있을 수 있습니다.
어쨌든 구조는 대략 위와 같고, start with ~ connect by ~ 문제를 대체하여

SELECT id, article_id, update_date, article_order, ROWNUM AS rnum, board_name, comm_name
FROM (
 SELECT id, article_id, update_date, article_order, ROWNUM AS rnum, board_name, comm_name
 FROM (
  SELECT t.id, t.article_id, t.update_date, t.article_order, board.name board_name, comm.name comm_name
  FROM tb_tree t, tb_tree board, tb_tree comm  WHERE t.board_id = board.id  AND t.comm_id = comm.id  AND t.comm_id = 174  AND board.status = 'Y'  ORDER BY article_order DESC) temp1 
 where article_id in ( 0 , 76 )  ORDER SIBLINGS BY update_date DESC ) temp2 
where rnum BETWEEN 1 and 10


이와 같이 만들었습니다.
하지만 이렇게 하면 order siblings by가 문제가 되어

ERROR: syntax error, unexpected IdName, expecting BY

라는 오류를 출력하는데요.
큐브리드 메뉴얼이나 홈페이지 등에서 검색을 해보고 알아보았으나 order siblings by에 대한
문제해결방법을 찾지 못하여 이렇게 문의를 하게 되었습니다.

siblings를 지워보고 실행하면 article_order 에 대한 정의가 불분명하여 alias 명을 붙여 분명하게 만들어야 하는데
몇가지 방법을 시도해 보았으나 원하는 검색 결과를 얻을 수 없어 이렇게 문의합니다.

  • ?
    남재우 2009.10.06 05:13
    안녕하세요.
    우선 문의하신 order siblings with 는 아직 지원되지 않습니다.
    간략하게 질의를 살펴보았는데 일단 order by desc 는 가급적 인덱스를 이용할 정렬방법을 사용하실 것을 권장합니다.
    또한 CUBRID 는 rownum between 10 and 20 과 같은 형태로 rownum 이 반드시 1부터 시작하지 않아도 되므로 where 절에 rownum 을 편리하게 사용할 수 있습니다.
    그리고 article_id 에 대한 부분은 우선 인덱스를 이용한 정렬방법을 쓰신후 문제가 되는지를 확인해 보시는 것이 좋겠습니다.
    문의하신 질의중 가장 안쪽 부분의 inline view 의 경우 ordered 힌트와 인덱스를 이용하여 정렬을 피할 수 있습니다.
    정렬대상인 article_order 가 tb_tree t 에 있다면 일단 인덱스를 만든후(create index r_article_order on tb_tree(artice_order desc))
    질의를 select /*+ ordered */ ... from tb_tree t, .. where ... and t.article_order >= 0 using index t.r_artice_order(+) 와 같이 하면 됩니다. 인덱스 사용을 위해 using index 를 추가했고 이에 대한 조건(article_order>=0)을 추가하여 사용하면 ordered 에 의해 tb_tree t 에 대하여 먼저 수행되며 이때 r_article_order 를 통한 인덱스 정렬효과를 얻을 수 있으며 이 결과에 대하여 순서대로 조인이 이루어 지므로 이 정렬결과를 그대로 유지시킬수가 있게 됩니다.

  1. CUBRID 사용자를 위한 DBeaver 도구 출시 안내

    Date2024.04.23 Byadmin Views118
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4474
    read more
  3. redhat 에서 cubrid 설치방법 문의

    Date2009.10.27 By레드코레아 Views21909
    Read More
  4. 시스템 테이블의 db_serial 값 수정에 관한 질문

    Date2009.10.27 By눈꽃 Views12414
    Read More
  5. 큐브리드 2008에서 모든 테이블 한번에 삭제 하는 쿼리는 어떻게 될까요?

    Date2009.10.24 By헬리 Views13898
    Read More
  6. db 의 데이터를 다른곳에서 똑 같이 만들려고 하는데요..

    Date2009.10.23 Bycoolbyj Views11189
    Read More
  7. linux (centOS) 에서 큐브리드 완전 삭제하기.

    Date2009.10.23 By미노군 Views16994
    Read More
  8. 0.5 이하 반올림 함수가 어떻게 되나요?

    Date2009.10.22 Bycoolbyj Views21274
    Read More
  9. 비트연산은 할 수 없나요?

    Date2009.10.22 By인경수 Views10238
    Read More
  10. mysql 에서 sum 함수를 큐브리드에서 동일하게 사용하려면....?

    Date2009.10.21 By눈꽃 Views13779
    Read More
  11. 서브쿼리 관련 질문입니다.

    Date2009.10.19 By눈꽃 Views10004
    Read More
  12. PHP 에서 ODBC 를 이용한 접근.

    Date2009.10.16 ByApiClasser Views12319
    Read More
  13. src.rpm에 있는 소스 중

    Date2009.10.16 By아주가끔은 Views10000
    Read More
  14. windows 2008 64비트에서 큐브리드 매니저 실행이 안되네요

    Date2009.10.15 By지니보이 Views11590
    Read More
  15. cubrid 설치 후 서버 기동 문제

    Date2009.10.13 By너와나 Views11026
    Read More
  16. loaddb 에러 발생.

    Date2009.10.09 By스팅거 Views10629
    Read More
  17. 컴파일 할 때 오류 cannot find -lcurses

    Date2009.10.08 By아주가끔은 Views12173
    Read More
  18. 클라이언트에서 원격지 DB로의 접속이 되지 않습니다...

    Date2009.10.08 By김동진81 Views14672
    Read More
  19. 7.1 -> 2008로 업그레이드 하면 문제가 없을까요?

    Date2009.10.07 By헬리 Views9825
    Read More
  20. db 초보자 입니다. 설치가 않되 질문 합니다.

    Date2009.10.06 Bywatertree Views9573
    Read More
  21. CUBRIDResultSetMetaData 에 관한 질문..

    Date2009.10.06 By눈꽃 Views10061
    Read More
  22. order siblings by 문의

    Date2009.10.06 By유쓰 Views21109
    Read More
Board Pagination Prev 1 ... 177 178 179 180 181 182 183 184 185 186 ... 200 Next
/ 200

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales