투케이2K

169. (Oracle/오라클) WITH 사용해 샘플 가상 임시 테이블 만들기 수행 본문

OracleDB

169. (Oracle/오라클) WITH 사용해 샘플 가상 임시 테이블 만들기 수행

투케이2K 2022. 5. 16. 15:05

[개발 환경 설정]

개발 툴 : Toad

개발 언어 : Oracle

 

[소스 코드]

/* [임시 가상 테이블 만들기 실시] */
WITH SAMPLE_USER AS 
(
  SELECT 1 AS IDX, '대조영' AS NAME, 27 AS AGE, 'M' AS SEX, '발해' AS DEPT FROM DUAL
  UNION ALL
  SELECT 2 AS IDX, '정혜공주' AS NAME, 17 AS AGE, 'G' AS SEX, '발해' AS DEPT FROM DUAL
  UNION ALL
  SELECT 3 AS IDX, '왕건' AS NAME, 25 AS AGE, 'M' AS SEX, '고려' AS DEPT FROM DUAL
  UNION ALL
  SELECT 4 AS IDX, '정순왕후' AS NAME, 51 AS AGE, 'G' AS SEX, '고려' AS DEPT FROM DUAL
  UNION ALL
  SELECT 5 AS IDX, '홍길동' AS NAME, 15 AS AGE, 'M' AS SEX, '조선' AS DEPT FROM DUAL
  UNION ALL
  SELECT 6 AS IDX, '장희빈' AS NAME, 21 AS AGE, 'G' AS SEX, '조선' AS DEPT FROM DUAL
  UNION ALL
  SELECT 7 AS IDX, '선덕여왕' AS NAME, 19 AS AGE, 'G' AS SEX, '신라' AS DEPT FROM DUAL
  UNION ALL
  SELECT 8 AS IDX, '천명공주' AS NAME, 18 AS AGE, 'G' AS SEX, '신라' AS DEPT FROM DUAL
  UNION ALL
  SELECT 9 AS IDX, '의자왕' AS NAME, 19 AS AGE, 'M' AS SEX, '백제' AS DEPT FROM DUAL
  UNION ALL
  SELECT 10 AS IDX, '온조' AS NAME, 16 AS AGE, 'M' AS SEX, '백제' AS DEPT FROM DUAL
  UNION ALL
  SELECT 11 AS IDX, '장수왕' AS NAME, 80 AS AGE, 'M' AS SEX, '고구려' AS DEPT FROM DUAL
  UNION ALL
  SELECT 12 AS IDX, '광개토대왕' AS NAME, 18 AS AGE, 'M' AS SEX, '고구려' AS DEPT FROM DUAL
)





/* [쿼리문 수행 실시] */
SELECT * -- 
    FROM SAMPLE_USER;
 

[결과 출력]

 

 

반응형
Comments