string_to_array, unnest, string_agg

yshjft·2024년 2월 11일
0

Postgresql

목록 보기
4/11

string_to_array

select string_to_array('72,71,70,', ',');  -- ['72', '71', '70', ]
select string_to_array('72,71,70,', null); -- ['7', '2', ',', '7', '1', ',', '7', '0', ','] 
select string_to_array('72,71,70,', 'a');  -- ['72,71,70,']
  • string_to_array(문자열, 구분자)
  • 구분자를 기준으로 문자열을 나누어 배열(text[] or _text)로 반환
  • Splits the string at occurrences of delimiter and forms the resulting fields into a text array.

unnest

  • unnest(배열)
  • 배열의 요소들을 개별 row로 펼쳐줍니다.
  • Expands an array into a set of rows. The array's elements are read out in storage order.

string_agg

  • 집계 함수
  • string_agg(컬럼명, 구분자)
  • 설정한 구분자를 이용하여 값들을 하나의 문자열로 합쳐줍니다.

참고 문서

profile
꾸준히 나아가자 🐢

0개의 댓글