반응형
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ■ WITH문 : 쿼리를 뷰처럼 재사용 -> WITH name AS ( 쿼리 ) 1.기본 WITH viewData AS ( SELECT * FROM TestTable_1 ) SELECT * FROM viewData; 2.WITH문에 다중 쿼리를 사용하는 CASE WITH viewData1 AS ( SELECT * FROM TestTable_1 ), viewData2 AS ( SELECT * FROM TestTable_2 ) SELECT V1.id, V2.name, V2.address FROM viewData1 V1, viewData2 V2 WHERE V1.id = V2.id AND V1.name LIKE 'H%'; 3.여러 테이블을 뷰 처럼 활용하는 CASE WITH viewData1 AS ( SELECT * FROM TestTable_1 ), viewData2 AS ( SELECT * FROM TestTable_2 ), viewData3 AS ( SELECT V1.id, V2.name, V2.address FROM viewData1 V1, viewData2 V2 WHERE V1.id = V2.id AND V1.name LIKE 'H%' ) SELECT * FROM viewData3 WHERE ROWNUM <= 10; | cs |
반응형