その先にあるもの…

배열 요소 null, array_replace 본문

프로그래밍/SQL

배열 요소 null, array_replace

specialJ 2023. 1. 10. 15:41

https://www.postgresql.org/docs/current/functions-array.html#ARRAY-FUNCTIONS-TABLE

 

array_length ( anyarray, integer ) → integer

Returns the length of the requested array dimension. (Produces NULL instead of 0 for empty or missing array dimensions.)

array_length(array[1,2,3], 1)3

array_length(array[]::int[], 1)NULL

array_length(array['text'], 2)NULL

 

array_replace ( anycompatiblearray, anycompatible, anycompatible ) → anycompatiblearray

Replaces each array element equal to the second argument with the third argument.

array_replace(ARRAY[1,2,5,4], 5, 3){1,2,3,4}



update tb_player set point = array_replace( point, null, 0 ) where array_length( point, 1 ) != 17



참조 : https://stackoverflow.com/questions/31108946/postgres-returns-null-instead-of-for-array-agg-of-join-table/33145722

 

'프로그래밍 > SQL' 카테고리의 다른 글

csv export / import  (0) 2022.10.11
펌) NOT IN 쿼리 성능 개선하기 (PostgreSQL)  (0) 2022.10.05
unique 제약조건과 인덱스  (0) 2022.09.26
펌)postgresql 자습서  (0) 2022.01.13
펌) [PostgreSQL] 시간값 다루기  (0) 2021.11.18
Comments