출처 : DBguide(hikim)님 EMP table을 이용하여, 직원들의 부서별 급여 순위를 보는 SQL 만들기.... 결과. EMPNO ENAME SAL DEPTNO RANK_DEPT ---------- ---------- ---------- ---------- ---------- 7839 KING 5000 10 1 --> 10번 부서의 1등 7782 CLARK 2450 10 2 7934 MILLER 1300 10 3 7788 SCOTT 3000 20 1 --> 20번 부서의 1등 7902 FORD 3000 20 2 7566 JONES 2975 20 3 7876 ADAMS 1100 20 4 7369 SMITH 800 20 5 7698 BLAKE 2850 30 1 7499 ALLEN 1600 30 2..
오라클
출처 : DBguide(jhouse)님 + ALL_ROWS - /*+ ALL_ROWS */ - 예 SELECT /*+ ALL_ROWS */ empno, ename, sal, job FROM emp WHERE empno = 7566; + FIRST_ROWS - /*+ FIRST_ROWS */ + CHOOSE - /*+ CHOOSE */ + RULE - /*+ RULE */ ** HINTs for Access Methods + FULL - /*+ FULL(table) */ - 예 SELECT /*+ FULL(a) Don't use the index on ACCNO */ accno, bal FROM accounts a WHERE accno = 7086854; + ROWID - /*+ ROWID(table) *..
sql>variable jobno number; sql>begin 2 sys.dbms_job.submit(:jobno, 'SP이름;', sysdate, 'TRUNC(SYSDATE) + 1', false); 3 End; 4 / sql>print jobno sql>exec dbms_job.run(21); sql>commit; 잡실행여부확인 sql>col what format a20 sql>select what, job, next_date, next_sec, failures, broken from user_jobs;잡강제실행 sql>exec dbms_job.run(21); 잡 Disable sql>exec dbms_job.broken(21, true); 잡 삭제 sql>exec dbms_job.remove(2..
정해진 날짜의 모든 날짜 구하기 SELECT ROWNUM, TO_DATE('20060425', 'YYYYMMDD') + (ROWNUM-1) FROM DICTIONARY WHERE ROWNUM BETWEEN 1 AND 15 SELECT ROWNUM, TO_DATE('20060425','YYYY-MM-DD')+(LEVEL-1) AS R_DT FROM DUAL CONNECT BY LEVEL
SELECT X.RES_NO, (NM_1||'|'||NM_2||'|'||NM_3||'|'||NM_4||'|'||NM_5||'|'||NM_6||'|'||NM_7||'|'||NM_8||'|'||NM_9||'|'||NM_10) AS ALL_NM FROM ( SELECT RES_NO , MAX(CASE SEQ WHEN 1 THEN B.DELI_KR_NM END) NM_1 , MAX(CASE SEQ WHEN 2 THEN B.DELI_KR_NM END) NM_2 , MAX(CASE SEQ WHEN 3 THEN B.DELI_KR_NM END) NM_3 , MAX(CASE SEQ WHEN 4 THEN B.DELI_KR_NM END) NM_4 , MAX(CASE SEQ WHEN 5 THEN B.DELI_KR_NM END..
DECLARE i INTEGER; BEGIN FOR I IN 1..32 LOOP INSERT INTO 테이블명 (컬럼명) VALUES (컬럼값); END LOOP; END;