
[Postgres] 기본적인 배열함수를 알아보자 ( feat. array_agg, array_to_string, string_to_array, unnest)
데이터베이스/쿼리
2022. 2. 3. 07:26
오늘은 Postgres에서 지원하는 기본적인 배열함수를 알아보자. 물론 툴은 DBeaver를 사용 할 것이고, 웹로그 테이블을 테스트 테이블로 사용한다. 1. array_agg 2. array_to_string, string_to_array 3. unnest 이렇게 3개의 함수를 지원한다. 그럼 바로 하나하나 알아보자. 1. array_agg ============================================================================ array_agg는 여러 row를 하나의 배열로 만들고자 할 때 사용하는 함수이다. inner조인으로 가져온 row값들은 보통 각각 다른 행으로 이루어 진다. 하지만 가져온 행값을 하나의 배열로 사용해야 할 때가 있다. 예를 들면..