본문 바로가기

오라클5

오라클(Oracle) 테이블 존재 여부 확인하기 오라클에서 테이블이 존재하는지 확인하는 방법. select count(*) from all_tables where table_name = '테이블 명'; 있으면 1 없으면 0 이렇게 쉬운걸... 2013. 3. 27.
오라클, start with connect by prior. 계층구조로 정렬하기. 1. 테이블 데이터 id=시퀀스, parent_id=부모키, name=자신의 이름, parent_name=부모의 이름, depth=단계 IDPARENT_IDNAMEPARENT_NAMEDEPTH30root1null140root2null153root1-1root1263root1-2root1273root1-3root1283root1-4root1298root1-4-1root1-43104root2-1root22114root2-2root222. 계층형 쿼리 SELECT ID, PARENT_ID, NAME, PARENT_NAME, TYPE FROM SITE_LIST START WITH PARENT_ID = 0 /* 부모의 시작 조건 */ CONNECT BY PRIOR ID = PARENT_ID /* 자신의 키와 부모.. 2013. 3. 25.
RANK() 함수 오라클 정리 RANK() 함수 partition by 그룹 order by 정렬 대상 select department_id, score, rank() over(partition by department_id order by score) rnk from (select 'a' department_id, 10 score from dual union all select 'b' department_id, 20 score from dual union all select 'a' department_id, 30 score from dual union all select 'b' department_id, 15 score from dual union all select 'a' department_id, 50 score f.. 2013. 3. 25.
오라클 업데이트 오라클 시스템에서 (여기서는 classification.articleID로 인덱스한 것을 가정함) UPDATE ( SELECT * FROM articles JOIN classification ON articles.articleID = classification.articleID WHERE classification.classID = 1 ) SET updated_column = updatevalue 2개의 테이블 join해서 A 테이블의 aa컬럼값을 B테이블에 bb 컬럼값으로 업데이트 하고 싶을때.. update /*+bypass_ujvc*/ ( select A.aa, B.bb from A, B where A.cc = B.cc ) set A.aa = B.bb 이렇게 하면 업데이트 된다. /*+bypass_.. 2013. 3. 25.