DB/ORACLE
ORACLE COLLECT()
yeon.Biju
2020. 3. 25. 14:40
오라클 COLLECT()
COLLECT is an aggregate function that takes as its argument a column of any type and creates a nested table of the input type out of the rows selected. Te get accurate results form this function you must use it within a CAST function.
아래 예제를 확인해볼려면 오라클에서 oe 계정을 활성화시켜야 한다.
SQL> ATLER USER OE ACCOUNT UNLOCK ;
SQL> ATLER USER OE IDENTIFIED BY 'OE12345678' ;
SQL> SELECT COLLECT(warehouse_name ORDER BY warehouse_name) as warehouse_name_t FROM warehouses;
--> warehouse_name의 여러개의 row 가 하나의 컬럼에 중첩된 형태로 데이타가 들어가있다.
* 흠.. 진작에 알았으면 잘 썼을 거 같은 함수다.